xml 中的 fragment
<fragment
android:id="@+id/parent_fragment"
android:name="com.app.example.ParentFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
在 Activity 中绑定(bind)
@BindView(R.id.parent_fragment)
ParentFragment parentFragment;
gradle 构建错误信息
@BindView fields must extend from View or be an interface
是否有类似@BindFragment
的东西用于使用@+id
绑定(bind)XML fragment ?
如果这是显而易见的事情,我很抱歉。
最佳答案
显然,那个库中没有这样的注释。
http://jakewharton.github.io/butterknife/
由于您的 Activity 中不会有很多 fragment ,因此可能没有必要使用库。只需使用 FragmentManager
parentFragment = (ParentFragment) getSupportFragmentManager().findFragmentById(R.id.parent_fragment);
关于android - 如何在 ButterKnife 中绑定(bind) XML fragment ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47050414/