I've got a project in which I'm trying to do some refactoring of my existing TabHosts. I've got a bunch of very simple TabHost files that look like the class below. Some actually only have one tab, some 3, etc - so the only real difference in them is the number of tabs and the activity class loaded in each one. I'd like to just create a single TabHost that could get the info out of a passed in Bundle to determine how many tabs and the info needed (spec, indicator, content) to build/add each tab. It seems like the items I can place in the bundle are pretty basic and I'm not familiar with the Parcelable or Serializable features. Any suggestions?
public class SomeTabHost
extends ActivityGroup
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// Inflate ourselves into the layout ViewStub
ViewStub vs = (ViewStub) findViewById(R.id.theViewStub);
vs.setLayoutResource(R.layout.my_tabhost);
vs.inflate();
TabHost host = (TabHost) findViewById(android.R.id.tabhost);
host.setup(getLocalActivityManager());
host.addTab(host.newTabSpec("Tab1")
.setIndicator("Tab1")
.setContent(new Intent(this, SomeActivity.class)));
host.addTab(host.newTabSpec("Tab2")
.setIndicator("Tab2")
.setContent(new Intent(this, SomeOtherActivity.class)));
int numChildren = host.getTabWidget().getChildCount();
for ( int i=0; i <numChildren; i++ )
{
host.getTabWidget().getChildAt(i).getLayoutParams().height = 35;
}
}// end onCreate
}// end class