我已經創建了標籤作爲視圖。但是我沒有找到關於如何操作這些視圖的任何信息。例如,如果我想顯示一個列表視圖和一個窗體(tablelayout)在另一個。我可以爲每個標籤分別設計佈局嗎?更重要的是,我在哪裏包含關於每個選項卡的Java代碼?如何處理標籤作爲視圖?
這裏是我的Java代碼:
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);
}
任何有點幫助表示讚賞。
好的。現在,如果我使用第二種方法,我可以爲我的選項卡使用單獨的佈局,還是必須將所有內容都包含在單個佈局中,例如我的活動? – Harsh
yourTabSpec.setContent(R.id.the_id_of_your_tab); –
要放在tabView中的「佈局」必須在選項卡主機的佈局中指定...查看它是如何做到的 –