Merge pull request #3353 from ByteHamster/searchview

Collapse search view
This commit is contained in:
H. Lehmann 2019-08-31 13:52:48 +02:00 committed by GitHub
commit 79199eec09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View File

@ -203,6 +203,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"/>