当我要添加将 TabGroupActivity 扩展为 TabHost 的 Activity 时,我的应用程序崩溃了。Fallowing 是代码。当我直接添加主页时,一切正常,但是当添加 HomePageTabGroup 时,应用程序不幸关闭。
MainTabHost.java
public class MainTabHost extends TabActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.maintabhost);
final TabHost tabHost = getTabHost();
//tabHost.getTabWidget().setDividerDrawable(R.drawable.tab_divider);
// Tab for Home
TabSpec home = tabHost.newTabSpec("Current Jobs");
// setting Title and Icon for the Tab
home.setIndicator("Current Jobs",getResources().getDrawable(R.drawable.icon_home_tab));
Intent homeIntent = new Intent(MainTabHost.this, HomePageTabGroup.class);
home.setContent(homeIntent);
// Adding all TabSpec to TabHost
tabHost.addTab(home); // Adding home tab
}
}
HomePageTabGroup.java
public class HomePageTabGroup extends TabGroupActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
startChildActivity("HomePage", new Intent(HomePageTabGroup.this, HomePage.class));
}
}