Reputation: 6013
I have the following layout, activity_main.xml
:
<merge
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<com.lorentzos.flingswipe.SwipeFlingAdapterView
android:id="@+id/frame"
android:background="#d1d1d1"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:rotation_degrees="15.5"
tools:context=".MainActivity"
android:layout_gravity="top"/>
<TextView
android:id="@+id/tv_noJobsLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:textStyle="bold"
android:textSize="18sp"
android:textColor="#474747"
android:textAlignment="center"
tools:text="Nothing Left to Swipe!"
android:layout_gravity="center" />
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<include layout="@layout/buttons" />
</merge>
In my main activity
, I have the following code for injection using ButterKnife
:
setContentView(R.layout.activity_main);
ButterKnife.inject(this);
I want to remove the <include>
part of the layout because I do not need those buttons anymore, however, when I remove the <include>
line I get the following error:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.lorentzos.swipecards.example/com.lorentzos.swipecards.MainActivity}: java.lang.RuntimeException: Unable to inject views for com.lorentzos.swipecards.MainActivity@f356341
What am I doing wrong?
Is there some reason why I cannot remove the <include>
?
EDIT:
@InjectView(R.id.frame) SwipeFlingAdapterView flingContainer;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Remove title bar
//this.requestWindowFeature(Window.FEATURE_NO_TITLE);
//color the notification bar with our company colors
Window window = this.getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.setStatusBarColor(this.getResources().getColor(R.color.laborswipe_notificationbar));
//remove title from action bar and add the logo to the top left of the action bar
setUpActionBar();
setContentView(R.layout.activity_main);
ButterKnife.inject(this);
Upvotes: 3
Views: 650
Reputation: 29794
After removing your <include layout=.../>
also remove the binded view from the layout in your activity.
Notes:
Binding views with ButterKnife
means that you have views in a layout with the binding codes in your main activity
. So there should be a code with:
@BindView(R.id.your_view_in_include_button) View yourViewName;
Remove this according with the view in your 'include layout. Then rebuild your app.
Suggestion:
Upgrade your ButterKnife to current version.
Upvotes: 1