Android ApiDemos示范解析(195):Views->Tabs->Content By Intent

Android ApiDemos示例解析(195):Views->Tabs->Content By Intent

本例使用可以启动其它Activity的Intent作为Tab页面的内容Content.

本例中使用的三个Activity分别为List1, List8, Control2 ,可以参见Android ApiDemos示例解析(168):Views->Lists->1. Array ,Android ApiDemos示例解析(175):Views->Lists->8. Photos 和Android ApiDemos示例解析(108):Views->Controls->2. Default Theme

final TabHost tabHost = getTabHost();

tabHost.addTab(tabHost.newTabSpec("tab1")
 .setIndicator("list")
 .setContent(new Intent(this, List1.class)));

tabHost.addTab(tabHost.newTabSpec("tab2")
 .setIndicator("photo list")
 .setContent(new Intent(this, List8.class)));

// This tab sets the intent flag so that it is recreated
// each time the tab is clicked.
tabHost.addTab(tabHost.newTabSpec("tab3")
 .setIndicator("destroy")
 .setContent(new Intent(this, Controls2.class)
 .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));

Android ApiDemos示范解析(195):Views->Tabs->Content By Intent