开发者

How do I hide a tab in a TabActivity?

开发者_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);   
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜