问题
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