У меня есть следующий макет, 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>
В моих main activity
, я следующий коде для инъекций с использованием :
setContentView(R.layout.activity_main);
ButterKnife.inject(this);
Я хочу, чтобы удалить <include>
части макета, потому что я больше не нужны эти кнопки, однако, когда я удаляю линию <include>
, я получаю следующую ошибку:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.lorentzos.swipecards.example/com.lorentzos.swipecards.MainActivity}: java.lang.RuntimeException: Unable to inject views for [email protected]
Что я делаю неправильно?
Есть ли причина, по которой я не могу удалить <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);
* ButterKnife.inject (this); * может быть это опечатка для 'ButterKnife.bind (this);'? –
После удаления вашего ' ' также удалите привязанный вид из макета в вашей деятельности. –
Я думаю, мне все еще нужна привязка, потому что она привязывает рамочный макет далее в xml? – user2573690