Reputation: 561
I have created three tabs in TabActivity onCreate.
How can I hide one tab at runtime?
Upvotes: 1
Views: 3916
Reputation: 4003
If you want to hide the tabWidget you can do so by setting the visibility to GONE
/INVISIBLE
like:
getTabWidget().setVisibility(TabWidget.GONE);
Upvotes: 1
Reputation: 3891
For Removing the particular tab from tabwidget :
tab = tabhost.getTabWidget().getChildTabViewAt(tabPosition); tabhost.getTabWidget().removeView(tab);
and for adding it back to tabwidget :
tabhost.getTabWidget().addView(tab);
OR
tabhost.getTabWidget().addView(tab,tabPosition);
Upvotes: 1
Reputation: 15699
To hide the tab you must remove it from the TabWidget. Just setting INVISIBLE is not enough. So, to hide the tab:
tab = getTabHost().getTabWidget().getChildTabViewAt(tabPosition);
getTabHost().getTabWidget().removeViewAt(tabPosition);
And to show that tab again:
getTabHost().getTabWidget().addView(tab, tabPosition);
Upvotes: 5