I've recently updated my apps to appcompat to v7:22.2.0. I have a searchview in the actionbar which was working fine before updating, but now the search field appears under the title when i press the search icon.
This is my 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, its fully functional, only the actionbar title is still displayed when using the SearchView. How can i prevent this from happening? Should i manually set the title to an empty string or is there a decent fix for 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 could hide the title here, but that's an ugly fix
return true;
}
@Override
public boolean onMenuItemActionCollapse(MenuItem item) {
hideSearch();
return true;
}
});