How to open SearchView in ActionBar programmatically?

1

Come on people, the question is this: I'm looking to open SearchView from a click on an item in Drawer (that side menu). So far I have seen several tutorials on, but I only find out how to open SearchView by clicking on the SerachView icon (the default way to open). If anyone knows a tutorial or knows how to do it, please explain me. Hugs!

    
asked by anonymous 11.02.2015 / 14:05

1 answer

1

In your OnClickListener, use:

myMenu.expandActionView() // ou collapseActionView(); 

Do not forget to add the menu actions:

MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW
    
11.02.2015 / 15:48