How to disable Action bar tab for fragments?

假装没事ソ 提交于 2019-12-13 14:12:36

问题


As i am using Action bar 3 tabs with fragments A,B,C want to disable B,C initially i am using

    ActionBar.Tab tab2 = ab.newTab();
    tab2.setText("PORT");
    tab2.setTabListener(this);
    tab2.setEnable(false);

but not allows me to use tab2.setEnable what is exact way to disable it?


回答1:


You have to remove a tab from the actionbar. Enable or disableing tabs is not supported. There is also no visibility function for tabs. You have to call:

ab.removeTab(tab2);

to remove a tab from the actionbar. But that does not require that you have to destroy (tab2 = null) your tab.



来源:https://stackoverflow.com/questions/21305546/how-to-disable-action-bar-tab-for-fragments

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!