我已經經歷了許多示例,問題和教程,但我從來沒有看到使用特定選項卡進行活動啓動(啓動新的意圖)。我知道可以使用.setCurrentTab
切換到選項卡,但這隻能在父活動選項卡內完成。如何從不同的活動啓動一個活動中包含的特定選項卡?可能嗎?如果是這樣,那麼怎麼樣?如何使用特定選項卡啓動活動?
在我的代碼中,標準活動啓動用戶顯示第一個選項卡,但是我希望他在第四個選項卡上進行重定向,以防其他活動重定向。 我TabHost代碼(MyTabActivity):
int tabIndex = 0;
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(tabIndex);
現在,在另一個活動:
public void gotoTab() {
//This will take me to the first tab
Intent i = new Intent(this, MyTabActivity.class);
startActivity(i);
finish();
//How to I make it take me to the fourth tab?
}