开发者_Python百科I have created three tabs in TabActivity onCreate.
How can I hide one tab at runtime?
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);
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);
If you want to hide the tabWidget you can do so by setting the visibility to GONE
/INVISIBLE
like:
getTabWidget().setVisibility(TabWidget.GONE);
精彩评论