我目前陷入困境。如果我正在使用带有碎片的actionbar(NAVIGATION_MODE_TABS)。我希望该片段是一个活动,它将处理所有视图加载和everything.currently fragmant类将扩展Fragment..Right?但我想要一些事情,比如扩展活动然后调用oncreate。
请帮忙。
enter code here
final TabHost tabHost = getTabHost();//(TabHost) findViewById(R.id.tabhost);// // The activity TabHost
TabHost.TabSpec spec; // Resusable TabSpec for each tab
Intent intent; // Reusable Intent for each tab
// Create an Intent to launch an Activity for the tab (to be reused)
intent = new Intent().setClass(this, X.class);
// Initialize a TabSpec for each tab and add it to the TabHost
spec = tabHost.newTabSpec("jbn jb n").setIndicator("gjngjmb ",
res.getDrawable(R.drawable.home))
.setContent(intent);
tabHost.addTab(spec);
// Do the same for the other tabs
intent = new Intent().setClass(this, MyCoursesActivity.class);
spec = tabHost.newTabSpec("my_course").setIndicator("My Courses",
res.getDrawable(R.drawable.courses))
.setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, DashboardActivity.class);
intent.putExtra("course_title", "Aal is well!!!");
spec = tabHost.newTabSpec("dashboard").setIndicator("Dashboard",
res.getDrawable(R.drawable.dashboard))
.setContent(intent);
tabHost.addTab(spec);
enter code here
此代码使用tabhost我想使用带有fragmants for android 4.0
的动作栏来做同样的事情答案 0 :(得分:0)
您可以在片段上使用onCreateView()
,getActivity().
也可以直接访问Activity