I’ve created tabs as views. But I didn’t find any info on how to manipulate theses views. For example if I want to display a listview in one and a form (tablelayout) in another. Can I have separate layouts for each tab? And more importantly where do I include java code regarding each tab?
Here’s my java code:
public class TabWorkEntryActivity extends TabActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tabworkentry);
TabHost mTabHost = getTabHost();
mTabHost.addTab(mTabHost.newTabSpec("top10").setIndicator("Top 10").setContent(R.id.Top_10));
mTabHost.addTab(mTabHost.newTabSpec("billable").setIndicator("Billable").setContent(R.id.Billable));
mTabHost.addTab(mTabHost.newTabSpec("product").setIndicator("Product").setContent(R.id.Product));
mTabHost.addTab(mTabHost.newTabSpec("regular").setIndicator("Regular").setContent(R.id.General));
mTabHost.setCurrentTab(3);
}
Any kinda help is appreciated.
There are two main ways of putting content and dealing with tabs:
1. you create an activity, and put the activity in the tabHost
2. you deal with the content, in the same code you add tabs (blow all the setup stuff)
I always use the 2nd way because my codes are organized, so it’s not so big…
Here is a sample layout, with the content as another layout…