我正在尝试使用tabhost及其创建问题

时间:2014-01-19 19:46:56

标签: java android android-tabhost

我正在尝试使用tabhost,它显示以下错误:

  

线程id = 1调用landroid / util / sparsearray时的StackOverflow;二进制搜索ILIII

为什么会这样?

这是我的代码:

setContentView(R.layout.menu);
TabHost mytabhost;
mytabhost=getTabHost();
TabSpec homespec=mytabhost.newTabSpec("home");
homespec.setIndicator("Home",getResources().getDrawable(R.drawable.home));
Intent homeintent=new Intent(getApplicationContext(),menu.class);
homespec.setContent(homeintent);

TabSpec infospec=mytabhost.newTabSpec("info");
infospec.setIndicator("Info",getResources().getDrawable(R.drawable.info));
Intent infointent=new Intent(getApplicationContext(),info.class);
infospec.setContent(infointent);

TabSpec servicespec=mytabhost.newTabSpec("Services");
servicespec.setIndicator("Services",getResources().getDrawable(R.drawable.services));
Intent serviceintent=new Intent(getApplicationContext(),services.class);
servicespec.setContent(serviceintent);

TabSpec onlinespec=mytabhost.newTabSpec("onlinetools");
onlinespec.setIndicator("Onlinetools",getResources().getDrawable(R.drawable.onlinetools));
Intent onlineintent=new Intent(getApplicationContext(),onlinetools.class);
onlinespec.setContent(onlineintent);

TabSpec mediaspec=mytabhost.newTabSpec("MediaCenter");
mediaspec.setIndicator("MediaCenter",getResources().getDrawable(R.drawable.mediacenter));
Intent mediaintent=new Intent(getApplicationContext(),mediacenter.class);
mediaspec.setContent(mediaintent);

mytabhost.addTab(homespec);
mytabhost.addTab(infospec);
mytabhost.addTab(servicespec);
mytabhost.addTab(onlinespec);
mytabhost.addTab(mediaspec);

0 个答案:

没有答案