I have a navigation drawer that links three fragments. All fragments have an ActionBar with different titles. Fragment A and B have no tabs, while Fragment C has tab 1 and tab 2. Navigating through them works fine and shows different ActionBar titles, but when I navigate from C to the other fragments, the tabs are still displayed in Fragment A and B's ActionBar. How do I "hide" the tabs when am navigating from C to Fragment A and B ?
Thanks
Switching between fragments
switch (possition) {
case 0:
fragment = new FragmentA();
break;
case 1:
fragment = new FragmentB();
break;
case 2:
fragment = new FragmentC();
break;
default:
break;
}
FragmentManager frgManager = getSupportFragmentManager();
frgManager.beginTransaction().replace(R.id.content_frame, fragment)
.commit();
Fragment C
private String[] tabs = { "1", "2"};
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_utilities, container, false);
viewPager = (ViewPager) rootView.findViewById(R.id.pager);
actionBar = ((ActionBarActivity)getActivity()).getSupportActionBar();
mAdapter = new TabsPagerAdapter(getActivity().getSupportFragmentManager());
viewPager.setAdapter(mAdapter);
actionBar.setHomeButtonEnabled(true);
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
for (String tab_name : tabs) {
actionBar.addTab(actionBar.newTab().setText(tab_name)
.setTabListener(UtilitiesFragment.this));
}