I am using the following code to setup a TabWidget:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TabHost mTabHost = getTabHost();
mTabHost.addTab(mTabHost.newTabSpec("tab_1").setIndicator("Tab1", getResources().getDrawable(R.drawable.tab_1)).setContent(new Intent(this, TabClass1.class)));
mTabHost.addTab(mTabHost.newTabSpec("tab_2").setIndicator("Tab2", getResources().getDrawable(R.drawable.tab_2)).setContent(new Intent(this, TabClass2.class)));
mTabHost.addTab(mTabHost.newTabSpec("tab_3").setIndicator("Tab3", getResources().getDrawable(R.drawable.tab_3)).setContent(new Intent(this, TabClass3.class)));
mTabHost.setCurrentTab(0);
}
So, TabClass1, TabClass2 and TabClass3 are separate .java files that are contained within my package. I am able to create content within each of these .java files and display the content when each tab is selected – but how do I assign an XML layout file to each of the .java files?
I have tried various setups but have been unable to create a TextView in an XML Layout and have it display when a particular tab is selected.
ok in your TabClass1.class you must have somethin like
your Layout myContentA.xml must be similar to…
you will reuse this xml layout in TabClass2.class and TabClass3.class or create myContentB.xml and myContentC.xml