android.widget.SearchView.setSuggestionsAdapter()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(4.2k)|赞(0)|评价(0)|浏览(104)

本文整理了Java中android.widget.SearchView.setSuggestionsAdapter()方法的一些代码示例,展示了SearchView.setSuggestionsAdapter()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SearchView.setSuggestionsAdapter()方法的具体详情如下:
包路径:android.widget.SearchView
类名称:SearchView
方法名:setSuggestionsAdapter

SearchView.setSuggestionsAdapter介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

, 0);
searchView.setSuggestionsAdapter(simple);
return true;

代码示例来源:origin: bparmentier/OpenBikeSharing

private void loadData(String query) {
  ArrayList<Station> queryStations = new ArrayList<>();
  String[] columns = new String[]{"_id", "text"};
  Object[] temp = new Object[]{0, "default"};
  MatrixCursor cursor = new MatrixCursor(columns);
  if (stations != null) {
    for (int i = 0; i < stations.size(); i++) {
      Station station = stations.get(i);
      if (station.getName().toLowerCase().contains(query.toLowerCase())) {
        temp[0] = i;
        temp[1] = station.getName();
        cursor.addRow(temp);
        queryStations.add(station);
      }
    }
  }
  searchView.setSuggestionsAdapter(new SearchStationAdapter(this, cursor, queryStations));
}

代码示例来源:origin: stackoverflow.com

// e.g in onCreateView in my Fragment, wire up the SearchView:
MenuItem searchMenuItem = toolbar.getMenu().findItem(R.id.search_menu_item);
SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchMenuItem);
// and setup listeners (implementation is shown later)
searchView.setOnSuggestionListener(this);
searchView.setOnQueryTextListener(this);
searchView.setOnCloseListener(this);
// then raid the SearchView so search begins on 0 chars!
AutoCompleteTextView autoCompleteTextView = (AutoCompleteTextView) searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text);
autoCompleteTextView.setThreshold(0);
// and set the suggestions adapter so we can use a Loader to do the queries
SuggestionCursorAdapter suggestionCursorAdapter = new SuggestionCursorAdapter(getContext(), null, 0);
searchView.setSuggestionsAdapter(suggestionAdapter);

代码示例来源:origin: stackoverflow.com

@Override
public boolean onCreateOptionsMenu(Menu menu) {
  //Used to put dark icons on light action bar
  boolean isLight = SampleList.THEME == R.style.Theme_Sherlock_Light;

  //Create the search view
  SearchView searchView = new SearchView(getSupportActionBar().getThemedContext());
  searchView.setQueryHint("Search for countries…");
  searchView.setOnQueryTextListener(this);
  searchView.setOnSuggestionListener(this);

  if (mSuggestionsAdapter == null) {
    MatrixCursor cursor = new MatrixCursor(COLUMNS);
    cursor.addRow(new String[]{"1", "'Murica"});
    cursor.addRow(new String[]{"2", "Canada"});
    cursor.addRow(new String[]{"3", "Denmark"});
    mSuggestionsAdapter = new SuggestionsAdapter(getSupportActionBar().getThemedContext(), cursor);
  }

  searchView.setSuggestionsAdapter(mSuggestionsAdapter);

  menu.add("Search")
    .setIcon(isLight ? R.drawable.ic_search_inverse : R.drawable.abs__ic_search)
    .setActionView(searchView)
    .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);

  return true;
}

代码示例来源:origin: stackoverflow.com

searchView.setSuggestionsAdapter(suggestionsAdapter);
suggestionsAdapter.notifyDataSetChanged();
searchView.setSuggestionsAdapter(suggestionsAdapter);
suggestionsAdapter.notifyDataSetChanged();

代码示例来源:origin: stackoverflow.com

final List<String> suggestions = new ArrayList<>();
searchView.setSuggestionsAdapter(suggestionAdapter);
searchView.setOnSuggestionListener(new SearchView.OnSuggestionListener() {
  @Override

代码示例来源:origin: stackoverflow.com

final List<String> suggestions = new ArrayList<>();
searchView.setSuggestionsAdapter(suggestionAdapter);
searchView.setOnSuggestionListener(new SearchView.OnSuggestionListener() {
  @Override

代码示例来源:origin: stackoverflow.com

final MenuItem searchMenuItem = menu.findItem(R.id.action_search);
final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchMenuItem);
searchView.setSuggestionsAdapter(new SimpleCursorAdapter(
    this,
    android.R.layout.simple_list_item_1,

代码示例来源:origin: stackoverflow.com

searchView.setSuggestionsAdapter(mAdapter);
searchView.setOnQueryTextListener(onQuerySearchView);
searchView.setOnSuggestionListener(onQuerySuggestion);

代码示例来源:origin: stackoverflow.com

searchView.setSuggestionsAdapter(mAdapter);
searchView.setOnQueryTextListener(onQuerySearchView);
searchView.setOnSuggestionListener(onQuerySuggestion);

相关文章