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

x33g5p2x  于2022-01-29 转载在 其他  
字(3.5k)|赞(0)|评价(0)|浏览(110)

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

SearchView.getSuggestionsAdapter介绍

暂无

代码示例

代码示例来源:origin: square/assertj-android

public SearchViewAssert hasSuggestionsAdapter(CursorAdapter adapter) {
 isNotNull();
 CursorAdapter actualAdapter = actual.getSuggestionsAdapter();
 assertThat(actualAdapter) //
   .overridingErrorMessage("Expected suggestions adapter <%s> but was <%s>.", adapter,
     actualAdapter) //
   .isSameAs(adapter);
 return this;
}

代码示例来源:origin: rsiebert/TVHClient

@Override
public boolean onSuggestionClick(int position) {
  searchMenuItem.collapseActionView();
  // Set the search query and return true so that the onQueryTextSubmit
  // is called. This is required to pass additional data to the search activity
  Cursor cursor = (Cursor) searchView.getSuggestionsAdapter().getItem(position);
  String suggestion = cursor.getString(cursor.getColumnIndex(SearchManager.SUGGEST_COLUMN_TEXT_1));
  searchView.setQuery(suggestion, true);
  return true;
}

代码示例来源:origin: tomahawk-player/tomahawk-android

@Override
  public boolean onQueryTextChange(String newText) {
    Cursor cursor = DatabaseHelper.get().getSearchHistoryCursor(newText);
    if (cursor.getCount() != 0) {
      String[] columns = new String[]{
          TomahawkSQLiteHelper.SEARCHHISTORY_COLUMN_ENTRY};
      int[] columnTextId = new int[]{android.R.id.text1};
      SuggestionSimpleCursorAdapter simple = new SuggestionSimpleCursorAdapter(
          getBaseContext(), R.layout.searchview_dropdown_item,
          cursor, columns, columnTextId, 0);
      if (searchView.getSuggestionsAdapter() != null
          && searchView.getSuggestionsAdapter().getCursor() != null) {
        searchView.getSuggestionsAdapter().getCursor().close();
      }
      searchView.setSuggestionsAdapter(simple);
      return true;
    } else {
      cursor.close();
      return false;
    }
  }
});

代码示例来源:origin: Phantast/smartnavi

public void handleMessage(Message msg) {
    if (msg.what == 0) {
      mSuggestionsAdapter = new SuggestionsAdapter(toolbar.getContext(), cursor);
      searchView.setSuggestionsAdapter(GoogleMap.mSuggestionsAdapter);
      // important to update suggestion list
      searchView.getSuggestionsAdapter().notifyDataSetChanged();
      suggestionsInProgress = false;
    }
    super.handleMessage(msg);
  }
};

代码示例来源:origin: tomahawk-player/tomahawk-android

@Override
  public boolean onSuggestionClick(int position) {
    SQLiteCursor cursor = (SQLiteCursor) searchView.getSuggestionsAdapter()
        .getItem(position);
    int indexColumnSuggestion = cursor
        .getColumnIndex(TomahawkSQLiteHelper.SEARCHHISTORY_COLUMN_ENTRY);
    searchView.setQuery(cursor.getString(indexColumnSuggestion), false);
    return true;
  }
});

代码示例来源:origin: tomahawk-player/tomahawk-android

@Override
public boolean onSuggestionSelect(int position) {
  SQLiteCursor cursor = (SQLiteCursor) searchView.getSuggestionsAdapter()
      .getItem(position);
  int indexColumnSuggestion = cursor
      .getColumnIndex(TomahawkSQLiteHelper.SEARCHHISTORY_COLUMN_ENTRY);
  searchView.setQuery(cursor.getString(indexColumnSuggestion), false);
  return true;
}

代码示例来源:origin: Phantast/smartnavi

@Override
  public boolean onQueryTextChange(String query) {
    // min 3 chars before autocomplete
    if (query.length() >= Config.PLACES_SEARCH_QUERY_CHARACTER_LIMIT) {
      // prevent hammering
      if (!suggestionsInProgress) {
        // get suggestions
        new PlacesAutoComplete().execute(query);
        suggestionsInProgress = true;
      }
    } else {
      // clear suggestion list
      mSuggestionsAdapter = new SuggestionsAdapter(sbContext, new MatrixCursor(Config.COLUMNS));
      searchView.setSuggestionsAdapter(mSuggestionsAdapter);
      searchView.getSuggestionsAdapter().notifyDataSetChanged();
    }
    return true;
  }
});

相关文章