# Action bar icons



## ermacwins (Jan 19, 2012)

Hi

Is it possible to enable/disable action bar icons? The scenario is that on the action bar there are two search icons, but they do different jobs, one searches the contents of the app while the other filters the listview (searches the table of contents only)

So if a user only wanted to use only one search method, is it possible to make an option in the settings on the app to enable/disable action bar icons?

Thanks


----------



## JBirdVegas (Jun 11, 2011)

I've never used ActionBars before but I guess, setVisibility of both to only show one at a time?

http://developer.android.com/reference/android/view/MenuItem.html#setVisible(boolean)

After quickly looking through the APIs I think I need to try the action bar lol


----------



## ermacwins (Jan 19, 2012)

JBirdVegas said:


> I've never used ActionBars before but I guess, setVisibility of both to only show one at a time?
> 
> http://developer.and...Visible(boolean)
> 
> After quickly looking through the APIs I think I need to try the action bar lol


Thanks but when you say at one at a time, can the icons in the action bar be toggled to show/hide anytime via settings?


----------



## JBirdVegas (Jun 11, 2011)

Check this out: http://stackoverflow.com/questions/8279981/how-can-i-change-action-bar-actions-dynamically

You treat the action bar as a menu. So when we want to change the list of buttons we invalidateOptionsMenu() then override onCreateOptionsMenu/onPrepareOptionsMenu there you can decide what icons you want to show.


----------

