Collapse search view

This commit is contained in:
ByteHamster 2019-08-30 23:22:40 +02:00
parent 8a3e4f8765
commit 0333b2cecf
2 changed files with 16 additions and 1 deletions

View File

@ -195,6 +195,21 @@ public class FeedItemlistFragment extends ListFragment {
final SearchView sv = (SearchView) MenuItemCompat.getActionView(searchItem);
MenuItemUtils.adjustTextColor(getActivity(), sv);
sv.setQueryHint(getString(R.string.search_hint));
searchItem.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {
@Override
public boolean onMenuItemActionExpand(MenuItem item) {
menu.findItem(R.id.filter_items).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
menu.findItem(R.id.episode_actions).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
menu.findItem(R.id.refresh_item).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
return true;
}
@Override
public boolean onMenuItemActionCollapse(MenuItem item) {
getActivity().invalidateOptionsMenu();
return true;
}
});
sv.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String s) {

View File

@ -33,7 +33,7 @@
<item
android:id="@+id/action_search"
android:icon="?attr/action_search"
custom:showAsAction="always"
custom:showAsAction="always|collapseActionView"
custom:actionViewClass="android.support.v7.widget.SearchView"
android:title="@string/search_label"/>