android - auto open searchin action bar only shows keyboard -
i trying have search bar in actionbar auto open when search page launched. use attempt open search bar automatically on page open:
@override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.main, menu); searchview searchview = (searchview) menu.finditem(r.id.menu_search).getactionview(); searchview.seticonified(false); searchview.setonquerytextlistener(this); return true; }
the problem when page opens, keyboard pops search bar not expand user can start typing search. looks this:
- use
searchitem.expandactionview();
and in menu file, use
showasaction="ifroom|collapseactionview"
if query, feel free comment.
Comments
Post a Comment