【发布时间】:2012-06-20 16:51:33
【问题描述】:
我浏览了许多示例、问题和教程,但从未见过带有特定选项卡的活动启动(启动新意图)。我知道可以使用.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?
}
【问题讨论】:
标签: android android-tabhost android-tabactivity android-tabs