How to open Searchview in Actionbar programmatically?

Asked

Viewed 289 times

1

Come on people, the question is as follows: I want to open Searchview from a click on an item in Drawer (that side menu). So far I have seen several tutorials about, but only find how to open Searchview by clicking on the Serachview icon (the default way to open). If anyone knows any tutorial or knows how to do, please explain to me. Hugs!

  • Have you made any of these solutions? http://stackoverflow.com/questions/24122448/always-expanded-searchview-not-in-the-action-bar/24123185#24123185?

1 answer

1

On your Onclicklistener, use:

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

Don’t forget to add menu actions:

MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW

Browser other questions tagged

You are not signed in. Login or sign up in order to post.