use of androidx.appcompat.widget.SearchView in project Rajawali by Rajawali.
the class ExamplesFragment method onCreateOptionsMenu.
@Override
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.menu_search, menu);
MenuItem menuItemSearch = menu.findItem(R.id.action_search);
SearchView searchView = (SearchView) menuItemSearch.getActionView();
searchView.setOnQueryTextListener(this);
}
use of androidx.appcompat.widget.SearchView in project collect by opendatakit.
the class SelectMinimalDialog method initSearchBar.
private void initSearchBar() {
getToolbar().inflateMenu(R.menu.select_minimal_dialog_menu);
SearchView searchView = (SearchView) getToolbar().getMenu().findItem(R.id.menu_filter).getActionView();
searchView.setQueryHint(getResources().getString(R.string.search));
searchView.setMaxWidth(Integer.MAX_VALUE);
searchView.onActionViewExpanded();
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
searchView.clearFocus();
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
viewModel.getSelectListAdapter().getFilter().filter(newText);
return false;
}
});
}
use of androidx.appcompat.widget.SearchView in project collect by opendatakit.
the class AppListFragment method onCreateOptionsMenu.
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
menu.clear();
inflater.inflate(R.menu.list_menu, menu);
final MenuItem sortItem = menu.findItem(R.id.menu_sort);
final MenuItem searchItem = menu.findItem(R.id.menu_filter);
final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
searchView.setQueryHint(getResources().getString(R.string.search));
searchView.setMaxWidth(Integer.MAX_VALUE);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
filterText = query;
updateAdapter();
searchView.clearFocus();
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
filterText = newText;
updateAdapter();
return false;
}
});
MenuItemCompat.setOnActionExpandListener(searchItem, new MenuItemCompat.OnActionExpandListener() {
@Override
public boolean onMenuItemActionExpand(MenuItem item) {
sortItem.setVisible(false);
return true;
}
@Override
public boolean onMenuItemActionCollapse(MenuItem item) {
sortItem.setVisible(true);
return true;
}
});
}
use of androidx.appcompat.widget.SearchView in project MovieGuide by esoxjem.
the class MoviesListingActivity method onCreateOptionsMenu.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
final MenuItem searchItem = menu.findItem(R.id.action_search);
final SearchView searchView = (SearchView) searchItem.getActionView();
final MoviesListingFragment mlFragment = (MoviesListingFragment) getSupportFragmentManager().findFragmentById(R.id.fragment_listing);
searchItem.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {
@Override
public boolean onMenuItemActionExpand(MenuItem item) {
return true;
}
@Override
public boolean onMenuItemActionCollapse(MenuItem item) {
MoviesListingFragment mlFragment = (MoviesListingFragment) getSupportFragmentManager().findFragmentById(R.id.fragment_listing);
mlFragment.searchViewBackButtonClicked();
return true;
}
});
searchViewTextSubscription = RxSearchView.queryTextChanges(searchView).debounce(500, TimeUnit.MILLISECONDS).subscribe(charSequence -> {
if (charSequence.length() > 0) {
mlFragment.searchViewClicked(charSequence.toString());
}
});
return true;
}
use of androidx.appcompat.widget.SearchView in project Signal-Android by signalapp.
the class CameraContactSelectionFragment method onPrepareOptionsMenu.
@Override
public void onPrepareOptionsMenu(@NonNull Menu menu) {
requireActivity().getMenuInflater().inflate(R.menu.camera_contacts, menu);
MenuItem searchViewItem = menu.findItem(R.id.menu_search);
SearchView searchView = (SearchView) searchViewItem.getActionView();
SearchView.OnQueryTextListener queryListener = new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
contactViewModel.onQueryUpdated(query);
return true;
}
@Override
public boolean onQueryTextChange(String query) {
contactViewModel.onQueryUpdated(query);
return true;
}
};
searchViewItem.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {
@Override
public boolean onMenuItemActionExpand(MenuItem item) {
searchView.setOnQueryTextListener(queryListener);
return true;
}
@Override
public boolean onMenuItemActionCollapse(MenuItem item) {
searchView.setOnQueryTextListener(null);
contactViewModel.onSearchClosed();
return true;
}
});
}
Aggregations