Можно разместить все ваши вкладки в разных видах деятельности.Создайте простой макет для родительского действия, что-то вроде этого:
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp">
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" />
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</TabHost>
Теперь вы создали желаемый макет вкладки, теперь пришло время заполнить вкладки требуемыми действиями.Это делается с помощью метода onCreate вашего TabActivity.
public class MyTabActivity extends TabActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Resources res = getResources(); // Resource object to get Drawables
TabHost tabHost = getTabHost(); // The activity TabHost
TabHost.TabSpec spec; // Resusable TabSpec for each tab
Intent intent; // Reusable Intent for each tab
// Create an Intent to launch an Activity for the tab (to be reused)
intent = new Intent().setClass(this, YourFirstActivity.class);
// Initialize a TabSpec for each tab and add it to the TabHost
spec = tabHost.newTabSpec("NameOfSpec").setIndicator("TabText1"),null).setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, YourSecondActivity.class);
spec = tabHost.newTabSpec("NameOfSpec2").setIndicator("TabText2",null).setContent(intent);
tabHost.addTab(spec);
tabHost.setCurrentTab(0);
}
}
Вот и все, теперь у вас есть вкладка с 2 вкладками, чтобы добавлять больше, просто продолжайте добавлять больше табосотов.И, конечно, вам нужно изменить текст для каждой вкладки и заполнить свои собственные действия вместо «YourFirstActivity» и «YourSecondActivity».
Для учебника, посмотрите здесь: http://developer.android.com/resources/tutorials/views/hello-tabwidget.html