我創建一個新選項卡界面內,每一個選項卡我有功能,例如:使用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