use of android.widget.SearchView in project OpenBikeSharing by bparmentier.
the class StationsListActivity method onCreateOptionsMenu.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
this.optionsMenu = menu;
getMenuInflater().inflate(R.menu.stations_list, menu);
if (jsonDownloadTask != null && (jsonDownloadTask.getStatus() == AsyncTask.Status.PENDING || jsonDownloadTask.getStatus() == AsyncTask.Status.RUNNING)) {
setRefreshActionButtonState(true);
}
SearchManager manager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
searchView.setSearchableInfo(manager.getSearchableInfo(getComponentName()));
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String s) {
return false;
}
@Override
public boolean onQueryTextChange(String s) {
loadData(s);
return true;
}
});
return true;
}
use of android.widget.SearchView in project android_packages_apps_Settings by crdroidandroid.
the class SearchFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.search_panel, container, false);
mResultsRecyclerView = view.findViewById(R.id.list_results);
mResultsRecyclerView.setAdapter(mSearchAdapter);
mResultsRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
mResultsRecyclerView.addOnScrollListener(mScrollListener);
mNoResultsView = view.findViewById(R.id.no_results_layout);
Toolbar toolbar = view.findViewById(R.id.search_toolbar);
getActivity().setActionBar(toolbar);
getActivity().getActionBar().setDisplayHomeAsUpEnabled(true);
mSearchView = toolbar.findViewById(R.id.search_view);
mSearchView.setQuery(mQuery, false);
mSearchView.setOnQueryTextListener(this);
mSearchView.requestFocus();
// Updating internal views inside SearchView was the easiest way to get this too look right.
// Instead of grabbing the TextView directly, we grab it as a view and do an instanceof
// check. This ensures if we return, say, a LinearLayout in the tests, they won't fail.
View searchText = mSearchView.findViewById(com.android.internal.R.id.search_src_text);
if (searchText instanceof TextView) {
TextView searchTextView = (TextView) searchText;
searchTextView.setTextColor(getContext().getColorStateList(com.android.internal.R.color.text_color_primary));
searchTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.search_bar_text_size));
}
View editFrame = mSearchView.findViewById(com.android.internal.R.id.search_edit_frame);
if (editFrame != null) {
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) editFrame.getLayoutParams();
params.setMarginStart(0);
editFrame.setLayoutParams(params);
}
ActionBarShadowController.attachToRecyclerView(view.findViewById(R.id.search_bar_container), getLifecycle(), mResultsRecyclerView);
return view;
}
use of android.widget.SearchView in project android-support-v4-googlemaps by petedoyle.
the class CursorFragment method onCreateOptionsMenu.
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
// Place an action bar item for searching.
MenuItem item = menu.add("Search");
item.setIcon(android.R.drawable.ic_menu_search);
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
SearchView sv = new SearchView(getActivity());
sv.setOnQueryTextListener(this);
item.setActionView(sv);
}
use of android.widget.SearchView in project weiciyuan by qii.
the class SearchMainParentFragment method onCreateOptionsMenu.
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.actionbar_menu_searchmainactivity, menu);
final SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
searchView = (SearchView) menu.findItem(R.id.search).getActionView();
searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
searchView.setImeOptions(EditorInfo.IME_ACTION_SEARCH);
searchView.setIconifiedByDefault(false);
searchView.setSubmitButtonEnabled(false);
searchView.setMaxWidth(Utility.dip2px(250));
ThemeUtility.customActionBarSearchViewTextColor(searchView);
searchView.requestFocus();
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
search(q);
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
SearchMainParentFragment.this.q = newText;
return false;
}
});
searchView.setOnSearchClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
search(q);
}
});
if (!TextUtils.isEmpty(this.q)) {
searchView.setQuery(this.q, false);
}
}
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 (config.isEnableExchangeRates()) {
final SearchView searchView = (SearchView) searchMenuItem.getActionView();
searchView.setOnQueryTextListener(new OnQueryTextListener() {
@Override
public boolean onQueryTextChange(final String newText) {
viewModel.setConstraint(Strings.emptyToNull(newText.trim()));
maybeSubmitList();
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 EditText searchInput = searchView.findViewById(id);
searchInput.setTextColor(activity.getColor(R.color.fg_on_dark_bg_network_significant));
searchInput.setHintTextColor(activity.getColor(R.color.fg_on_dark_bg_network_insignificant));
} else {
searchMenuItem.setVisible(false);
}
super.onCreateOptionsMenu(menu, inflater);
}
Aggregations