Search code examples
androidandroid-actionbar

android actionbar - removing the actionbar dynamically


I want to use an activity in two manners

  1. It shows a list of items which can be edited, new ones added etc
  2. It shows the list of items in order to choose one.

As the main logic of the Activity is to display the list of items I would like to handle these two cases in the same Activity. Nevertheless in the 1. I want to show the actionbar so that the user can navigate from there to wherever wanted. In the 2. case I dont want any actionbar to be shown, all the user can do is choose an item or press cancel/back.

What is the best way to achieve this. My first guess would be two themes which I set dynamically what of the two cases is required. But I wonder if there is also a way to easily remove the actionbar from the screen programmatically which would save me from declaring two themes etc. Any suggestion how you handle this requirement would be very helpful.

Thanks


Solution

  • How about this?

    public void hideActionBar(){
        getActionBar().hide();
    }
    

    Source: http://developer.android.com/guide/topics/ui/actionbar.html