我想更改标签的内容? 当创建tha选项卡时,我通过setContent()方法设置选项卡的内容。但是,如果我再次点击,我想要更改意味着更改为其他活动的内容。
我使用了setOnTabChangedListener()方法,但我不确定如何将内容设置为另一个意图?
Resources res = getResources();
TabHost tabHost=getTabHost();
tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("HOME").setContent(new Intent(getBaseContext(),homeGroup.class)));
tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator("ABOUT US").setContent(new Intent(getBaseContext(),aboutusGroup.class)));
tabHost.setCurrentTab(0);
tabHost.setOnTabChangedListener(new OnTabChangeListener()
{
@Override
public void onTabChanged(String tabId)
{
//here i want to set the content of each tab to another intent
// for 'tab1', change to home.class
// for 'tab2', change to aboutus.class
//how to set these?
}
});
请帮帮我.. 谢谢..
答案 0 :(得分:1)
答案 1 :(得分:0)
您无需在标签中更改活动内容以容纳新的活动内容。
相反,您需要使用ActivityGroup。
检查此处的链接
Changing the view within the Android Tab Widget
http://ericharlow.blogspot.com/2010/09/experience-multiple-android-activities.html
希望有所帮助:)