【发布时间】:2014-10-20 15:09:50
【问题描述】:
我正在尝试为我的 android 应用程序构建一个 TabView。这是我的java代码
public class AllMain extends TabActivity{
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.all_main);
// create the TabHost that will contain the Tabs
TabHost tabHost = getTabHost();
Resources res = getResources();
TabSpec tab1 = tabHost.newTabSpec("First Tab").setIndicator("Tab1").setContent(new Intent().setClass(this, TabAll_all.class));
TabSpec tab2 = tabHost.newTabSpec("Second Tab").setIndicator("Tab2").setContent(new Intent().setClass(this, TabAll_all.class));
TabSpec tab3 = tabHost.newTabSpec("Third tab").setIndicator("Tab3").setContent(new Intent().setClass(this, TabAll_all.class));
tabHost.addTab(tab3);
tabHost.addTab(tab1);
tabHost.addTab(tab2);
tabHost.setCurrentTab(0);
}
}
但是当我运行应用程序时,应用程序关闭并显示“不幸停止”消息。
我意识到在下面的行评论不会给我错误
tabHost.addTab(tab3);
tabHost.addTab(tab1);
tabHost.addTab(tab2);
提前致谢。
【问题讨论】:
标签: android android-tabhost tabview