android : Dynamically changing the content of tab
Posted
by
Jomia
on Stack Overflow
See other posts from Stack Overflow
or by Jomia
Published on 2011-02-21T09:59:04Z
Indexed on
2012/10/01
9:38 UTC
Read the original article
Hit count: 148
I want to change the content of a tab? when tha tab is created i set the content of the tab by setContent() method. But if I click again, I want to change the content that means change to another activity.
I used setOnTabChangedListener() method, but I am not sure about how to set the content to another intent?
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?
}
});
Please help me.. Thank you..
© Stack Overflow or respective owner