use of android.widget.SearchView in project android_frameworks_base by DirtyUnicorns.
the class SelectPrinterActivity method onCreateOptionsMenu.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.select_printer_activity, menu);
MenuItem searchItem = menu.findItem(R.id.action_search);
SearchView searchView = (SearchView) searchItem.getActionView();
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return true;
}
@Override
public boolean onQueryTextChange(String searchString) {
((DestinationAdapter) mListView.getAdapter()).getFilter().filter(searchString);
return true;
}
});
searchView.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
@Override
public void onViewAttachedToWindow(View view) {
if (AccessibilityManager.getInstance(SelectPrinterActivity.this).isEnabled()) {
view.announceForAccessibility(getString(R.string.print_search_box_shown_utterance));
}
}
@Override
public void onViewDetachedFromWindow(View view) {
if (!isFinishing() && AccessibilityManager.getInstance(SelectPrinterActivity.this).isEnabled()) {
view.announceForAccessibility(getString(R.string.print_search_box_hidden_utterance));
}
}
});
return true;
}
use of android.widget.SearchView in project android_packages_apps_Settings by LineageOS.
the class PrintServiceSettingsFragment method onCreateOptionsMenu.
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.print_service_settings, menu);
MenuItem addPrinters = menu.findItem(R.id.print_menu_item_add_printer);
if (mServiceEnabled && mAddPrintersIntent != null) {
addPrinters.setIntent(mAddPrintersIntent);
} else {
menu.removeItem(R.id.print_menu_item_add_printer);
}
MenuItem settings = menu.findItem(R.id.print_menu_item_settings);
if (mServiceEnabled && mSettingsIntent != null) {
settings.setIntent(mSettingsIntent);
} else {
menu.removeItem(R.id.print_menu_item_settings);
}
MenuItem searchItem = menu.findItem(R.id.print_menu_item_search);
if (mServiceEnabled && mPrintersAdapter.getUnfilteredCount() > 0) {
mSearchView = (SearchView) searchItem.getActionView();
mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return true;
}
@Override
public boolean onQueryTextChange(String searchString) {
mPrintersAdapter.getFilter().filter(searchString);
return true;
}
});
mSearchView.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
@Override
public void onViewAttachedToWindow(View view) {
if (AccessibilityManager.getInstance(getActivity()).isEnabled()) {
view.announceForAccessibility(getString(R.string.print_search_box_shown_utterance));
}
}
@Override
public void onViewDetachedFromWindow(View view) {
Activity activity = getActivity();
if (activity != null && !activity.isFinishing() && AccessibilityManager.getInstance(activity).isEnabled()) {
view.announceForAccessibility(getString(R.string.print_search_box_hidden_utterance));
}
}
});
} else {
menu.removeItem(R.id.print_menu_item_search);
}
}
use of android.widget.SearchView in project SEProject by NicholasBarreyre.
the class TeamActivity method onCreateOptionsMenu.
/**
* Configures options menu
*
* @param menu
* @return
*/
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_team, menu);
MenuItem searchItem = menu.findItem(R.id.action_join_team);
SearchView searchView = (SearchView) searchItem.getActionView();
searchView.setSearchableInfo(((SearchManager) getSystemService(Context.SEARCH_SERVICE)).getSearchableInfo(getComponentName()));
searchView.onActionViewExpanded();
return true;
}
use of android.widget.SearchView in project bitcoin-wallet by bitcoin-wallet.
the class ExchangeRatesFragment method onCreateOptionsMenu.
@Override
public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) {
inflater.inflate(R.menu.exchange_rates_fragment_options, menu);
final MenuItem searchMenuItem = menu.findItem(R.id.exchange_rates_options_search);
if (Constants.ENABLE_EXCHANGE_RATES) {
final SearchView searchView = (SearchView) searchMenuItem.getActionView();
searchView.setOnQueryTextListener(new OnQueryTextListener() {
@Override
public boolean onQueryTextChange(final String newText) {
query = Strings.emptyToNull(newText.trim());
getLoaderManager().restartLoader(ID_RATE_LOADER, null, rateLoaderCallbacks);
return true;
}
@Override
public boolean onQueryTextSubmit(final String query) {
searchView.clearFocus();
return true;
}
});
// Workaround for not being able to style the SearchView
final int id = searchView.getContext().getResources().getIdentifier("android:id/search_src_text", null, null);
final View searchInput = searchView.findViewById(id);
if (searchInput instanceof EditText)
((EditText) searchInput).setTextColor(Color.WHITE);
} else {
searchMenuItem.setVisible(false);
}
super.onCreateOptionsMenu(menu, inflater);
}
use of android.widget.SearchView in project ShelterApp by farzamtn.
the class ShelterItemListActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_shelteritem_list);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
toolbar.setTitle(getTitle());
// Show the Up button in the action bar.
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
View recyclerView = findViewById(R.id.shelteritem_list);
assert recyclerView != null;
setupRecyclerView((RecyclerView) recyclerView);
SearchView searchBar = (SearchView) findViewById(R.id.search_bar);
searchBar.setQueryHint("Search Shelters");
searchBar.setSubmitButtonEnabled(true);
searchBar.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
if (query == null || query.equals("")) {
setupRecyclerView((RecyclerView) recyclerView);
}
setupRecyclerView((RecyclerView) recyclerView, searchBar.getQuery());
return true;
}
@Override
public boolean onQueryTextChange(String query) {
if (query == null || query.equals("")) {
setupRecyclerView((RecyclerView) recyclerView);
}
setupRecyclerView((RecyclerView) recyclerView, searchBar.getQuery());
return true;
}
});
if (findViewById(R.id.shelteritem_detail_container) != null) {
// The detail container view will be present only in the
// large-screen layouts (res/values-w900dp).
// If this view is present, then the
// activity should be in two-pane mode.
mTwoPane = true;
}
}
Aggregations