android - Search widget doesn't integrate with toolbar, when calling onSearchRequested() -


i created xml file in menu folder search item.

<item android:id="@+id/action_search"     android:title="@string/search_hint"     android:icon="@drawable/ic_magnify_white_24dp"     app:showasaction="collapseactionview|ifroom"     app:actionviewclass="android.support.v7.widget.searchview"     /> 

i setup menu search function

@override     public boolean oncreateoptionsmenu(menu menu) {         // inflate menu items use in action bar         menuinflater inflater = getmenuinflater();         inflater.inflate(r.menu.menu_option, menu);          // associate searchable configuration searchview         searchmanager searchmanager =                 (searchmanager) this.getsystemservice(context.search_service);         searchview searchview =                 (searchview) menu.finditem(r.id.action_search).getactionview();         searchview.setsearchableinfo(                 searchmanager.getsearchableinfo(getcomponentname()));          return super.oncreateoptionsmenu(menu);     }      @override     public boolean onoptionsitemselected(menuitem item) {         // handle presses on action bar items         switch (item.getitemid()) {             case r.id.action_search:                 //start search activity here                 onsearchrequested();                 return true;             default:                 return super.onoptionsitemselected(item);         }     } 

the problem when i'm calling onsearchrequested(), search widget not integrate toolbar. see image: enter image description here should (and when i'm not calling onsearchrequested(). thought documentation says, onsearchrequested needs called?): enter image description here search widget loads twice. enter image description here

any appreciated. thanks!


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -