android : Dynamically changing the content of tab
- by Jomia
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..