コード例 #1
0
  /** Query rewriting. show selection in edittext */
  private void rewriteQueryFromSuggestion(int position, CursorAdapter adapter) {
    CharSequence oldQuery = mEditorTextView.getText();

    Cursor c = adapter.getCursor();
    if (c == null) {
      return;
    }

    if (c.moveToPosition(position)) {
      // Get the new query from the suggestion.
      CharSequence newQuery = adapter.convertToString(c);
      if (newQuery != null) {
        // The suggestion rewrites the query.
        // Update the text field, without getting new suggestions.
        setQuery(newQuery);
      } else {
        // The suggestion does not rewrite the query, restore the user's
        // query.
        setQuery(oldQuery);
      }
    } else {
      // We got a bad position, restore the user's query.
      setQuery(oldQuery);
    }
  }
コード例 #2
0
 /**
  * Called by the SuggestionsAdapter
  *
  * @hide
  */
 /* package */ void onQueryRefine(CharSequence queryText) {
   setQuery(queryText);
 }