问题描述
我正在观看教师使用的教程
test = view.getRootView().findViewById(R.id.test);
在片段中的 onViewCreated() 内部。
就像这样:
@Override
public void onViewCreated(@NonNull @NotNull View view,@Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
super.onViewCreated(view,savedInstanceState);
//test is just a TextView for testing the application,will remove it later
test = view.getRootView().findViewById(R.id.test);
}
使用 view.getRootView().findViewById()
与仅使用 view.findViewById()
相比有什么意义吗?我对讲师使用的 getRootView()
的目的有点困惑。
谢谢!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)