I really doubt that having 3 tabs instead of 4 will noticeably change performance. You need to have as many tabs as suits your app. In my app, I need 4 tabs because if I had 3, then the use ability would be bad, and it would be confusing to navigate.
If you want 5+ tabs, then I d recommend doing away with the tabwidget and then implement your own custom layout (possibly a horiziontal scrollview) as is implemented in WeatherBug. Then on that custom layout, on each button or imageView or whatever is in your custom layout, you would call setCurrentTab
in an onClick for the views.
我有4个这样的表格:
intent = new Intent().setClass(this, ActivityTabOther.class);
spec = tabHost.newTabSpec("other").setIndicator("General",
res.getDrawable(R.drawable.other))
.setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, ActivityTabLocate.class);
spec = tabHost.newTabSpec("locate").setIndicator("Locate",
res.getDrawable(R.drawable.locate))
.setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, ActivityTabSecure.class);
// Initialize a TabSpec for each tab and add it to the TabHost
spec = tabHost.newTabSpec("secure").setIndicator("Secure",
res.getDrawable(R.drawable.secure))
.setContent(intent);
tabHost.addTab(spec);
//If you want to remove a tab, delete everything from here down, and that s minus one tab.
intent = new Intent().setClass(this, ActivityTabFriends.class);
// Initialize a TabSpec for each tab and add it to the TabHost
spec = tabHost.newTabSpec("friends").setIndicator("Friends",
res.getDrawable(R.drawable.findabuddy))
.setContent(intent);
tabHost.addTab(spec);