我创建一个新选项卡界面内,每一个选项卡我有功能,例如:使用findViewById片段
public class ClassViewFragment extends Fragment {
ListView classListView = null;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.class_view, container, false);
classListView = (ListView) findViewById(R.id.classList);
return rootView;
}
}
但我正在逐渐cannot resolve method findViewById
也在另一个地方我也无法使用runOnUiThread
并获得Error:(88, 29) error: cannot find symbol method runOnUiThread(<anonymous Runnable>)
我知道这些将工作正常,如果我的课程从Activity
扩展,但它是一个选项卡片段,所以我如何使用此功能?
'classListView =(ListView中)rootView.findViewById(R.id。班级列表); – DeeV 2015-01-20 18:45:25
可能重复的[findViewById在片段android](http://stackoverflow.com/questions/6495898/findviewbyid-in-fragment-android)...什么可以通过简单的谷歌搜索... – Selvin 2015-01-20 19:38:03
@Selvin是的它是。让投票关闭它作为重复的[findViewById在片段](http://stackoverflow.com/questions/6495898/findviewbyid-in-fragment)! :) – Sufian 2016-10-20 07:44:23