【发布时间】:2016-09-18 16:00:51
【问题描述】:
我有一个包含自定义视图的片段。
在片段中,我像这样执行ButterKnife.bind:
View root = inflater.inflate(R.layout.fragment_home, container, false);
ButterKnife.bind(this, root);
我设法绑定视图。
现在,片段包含我创建的自定义视图。
在MenuToggleButton自定义视图中我想绑定另一个视图,并对其进行操作。
我遇到的问题是,我不知道如何从自定义视图(在片段中)内部访问片段的根视图。
public MenuToggleButton(Context context, AttributeSet attrs) {
super(context, attrs);
final Activity activity = (Activity) context;
ButterKnife.bind(this, // need to get the fragment root view somehow);
}
我怎样才能获得片段根视图以便像在片段中那样绑定它?
【问题讨论】:
-
This 可以帮到你。
标签: android android-fragments android-view butterknife