There is no method like hideTab for hiding ActionBar Tab, but we can achieve the same effect by using ActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD). If we use add fragment when calling a fragment, we must override onHiddenChange(boolean hidden) fragment method to check if fragment is shown or not then determine to show or hide the tabs.
Here the code in action:
ActionBar mActionBar; // get action bar
@Override
public void onHiddenChanged(boolean hidden) {
super.onHiddenChanged(hidden);
if (hidden) {
//do when hidden
mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
} else {
//do when show
mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
}
}
This code will detect the fragment status whether hidden or not. If hidden value is true then the Tab will be hidden, if the hidden value is false then the Tab will be show.
Happy Programming ;)
0 comments:
Silahkan tinggalkan komentar anda: