У меня есть CoordinatorLayout, где у меня есть моя кнопка:нож для масла не работает с Включают тег
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom|end">
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_marginBottom="16dp"
android:layout_marginRight="16dp"
android:src="@drawable/icon"
app:fabSize="normal"/>
</android.support.design.widget.CoordinatorLayout>
И тогда я имею XML Activity, где я включаю кнопку:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
...
<include
android:id="@+id/fabHere"
layout="@layout/fab_here"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
И здесь я есть фрагмент с ножом для масла:
public class MyFragment extends Fragment {
....
@BindView(R.id.fab) FloatingActionButton fab;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
view = inflater.inflate(R.layout.my_fragment, container, false);
ButterKnife.bind(this, view);
return view;
}
...
}
Но если я запускаю приложение это выглядит:
java.lang.IllegalStateException: Требуемый вид 'fab' с ID 2131624072 для поля 'fabHere' не найден. Если это представление необязательно, добавьте примечание «@Nullable» (поля) или «@Optional» (методы).
Я пытался добавить аннотаций в '@Nullable' и '@optional', но он не работает
Что произойдет, если вы удалите 'android: id =" @ + id/fabHere "'? – Blackbelt
ничего не происходит –
Что именно вы имеете в виду, ничего не происходит? Это рухнет, разве это ничего не показывает? Используйте 'Butterknife.setDebug (true)' –