android - Appcompat 22.2.0 SearchView appears under title -
i've updated apps appcompat v7:22.2.0. have searchview in actionbar working fine before updating, search field appears under title when press search icon.
this code:
<menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <item android:id="@+id/search_participants" android:icon="@drawable/search_white" android:title="@string/search" app:actionviewclass="android.support.v7.widget.searchview" app:showasaction="collapseactionview|always"/> </menu>
it still works, functional, actionbar title still displayed when using searchview. how can prevent happening? should manually set title empty string or there decent fix this?
@override public void onprepareoptionsmenu(menu menu) { super.onprepareoptionsmenu(menu); moptionsmenu = menu; if (moptionsmenu != null) { menu.clear(); mmenuinflater.inflate(r.menu.live_tracking_overview_menu, menu); msearchitem = menu.finditem(r.id.search_participants); msearchview = (searchview) menuitemcompat.getactionview(msearchitem); msearchview.setonquerytextlistener(this); msearchview.setqueryhint(getstring(r.string.search)); menuitemcompat.setonactionexpandlistener(msearchitem, new menuitemcompat.onactionexpandlistener() { @override public boolean onmenuitemactionexpand(menuitem item) { showsearch(); //i hide title here, that's ugly fix return true; } @override public boolean onmenuitemactioncollapse(menuitem item) { hidesearch(); return true; } });
Comments
Post a Comment