2

Is there a way, how to delete actionbar (all his tabs and settings)?

I'm trying something like:

  public void setUpActionBar(int selTab) {

    if (thereIsSomeActionBar){
          deleteThatActionBar();
       }

    ActionBar actionBar = getSupportActionBar();

    ....set up new actionbar

    }
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Miloš Lukačka
  • 842
  • 1
  • 11
  • 25
  • 1
    what do you mean "delete the action bar"? what are you trying to achieve? – Ovidiu Latcu Sep 03 '12 at 08:37
  • I'm trying to create actionbar. this method is called onResume(), and somethimes, count of tabs changes, and I want to create new actionbar with that count of tabs. imagine, you start the app, and actionbar with 5 tabs is created. then you go to settings (another activity) and set that you want only 4 tabs, and then, when you go back, there should be actionbar with 4 tabs. but when I do it, it shows actionbar with 9 tabs (5 original and 4 new, correct tabs). so I'm trying to delete that 5 tabs first – Miloš Lukačka Sep 03 '12 at 08:40
  • http://stackoverflow.com/a/8518634/1012284 – Padma Kumar Sep 03 '12 at 08:43

1 Answers1

1

You can call getActionBar().removeAllTabs() to remove all the tabs from the ActionBar.

You also can call invalidateOptionsMenu() on your Activity to force the re-creation of your options in the ActionBar.

Ovidiu Latcu
  • 71,607
  • 15
  • 76
  • 84