我目前被困在某一点上。如果我使用带有片段的操作栏(NAVIGATION_MODE_TABS)。我希望片段是一个将处理所有视图加载和所有内容的活动.目前fragmant类将扩展片段。对?但我想要一些东西,比如扩展活动然后调用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,我想使用带有 android 4.0 脆弱的动作栏做同样的事情
您可以在
Fragment上使用onCreateView()
,并且getActivity().
将使您直接访问Activity