0

How can I completely remove the ActionBar from Certain Fragments. I want to remove it not just to hide it. I have Actionbar Tab Navigation. From that i added a new Fragmnt which didn't need actionBar. So i need to remove it. I can't hide it because when i pressed back button and moved to Tabs section, i need to show Action bar again.

This is how i am replacing Fragments.

FragmentManager fragmentManager = getSupportFragmentManager();
            fragmentManager.beginTransaction()
                    .add(R.id.frame_container, fragment)
                    .addToBackStack(null).commit();
Abid Khan
  • 2,451
  • 4
  • 22
  • 45

2 Answers2

0

The action bar is not part of your fragment. It's part of your activity.

You can create a new Activity with a theme Theme.Holo.Light.NoActionBar and open this Activity with :

getActivity().startActivity(new Intent(getActivity(), SecondActivity.class));

And inside your second activity you can display the fragment you want. I recommend you this post to understand more the differences between Fragment and Activity: https://stackoverflow.com/a/10515807/3112836

Community
  • 1
  • 1
Arnaud
  • 509
  • 5
  • 13
0

If you're not using actionbar.hide() just because you have to show Action bar in other fragment, than I think you should give it a try by using : actionbar.hide() inside onAttach method of your fragment and actionBar.show() inside your onDestroy() method.

Montag451
  • 1,168
  • 3
  • 14
  • 30
Manish
  • 1,259
  • 3
  • 11
  • 20