當前位置: 首頁>>代碼示例>>Java>>正文


Java SearchManager.SUGGEST_COLUMN_INTENT_DATA_ID屬性代碼示例

本文整理匯總了Java中android.app.SearchManager.SUGGEST_COLUMN_INTENT_DATA_ID屬性的典型用法代碼示例。如果您正苦於以下問題:Java SearchManager.SUGGEST_COLUMN_INTENT_DATA_ID屬性的具體用法?Java SearchManager.SUGGEST_COLUMN_INTENT_DATA_ID怎麽用?Java SearchManager.SUGGEST_COLUMN_INTENT_DATA_ID使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.app.SearchManager的用法示例。


在下文中一共展示了SearchManager.SUGGEST_COLUMN_INTENT_DATA_ID屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: refreshShortcut

private Cursor refreshShortcut(Uri uri) {
  /* This won't be called with the current implementation, but if we include
   * {@link SearchManager#SUGGEST_COLUMN_SHORTCUT_ID} as a column in our suggestions table, we
   * could expect to receive refresh queries when a shortcutted suggestion is displayed in
   * Quick Search Box. In which case, this method will query the table for the specific
   * word, using the given item Uri and provide all the columns originally provided with the
   * suggestion query.
   */
  String rowId = uri.getLastPathSegment();
  String[] columns = new String[] {
      BaseColumns._ID,
      DictionaryDatabase.KEY_WORD,
      DictionaryDatabase.KEY_DEFINITION,
      SearchManager.SUGGEST_COLUMN_SHORTCUT_ID,
      SearchManager.SUGGEST_COLUMN_INTENT_DATA_ID};

  return mDictionary.getWord(rowId, columns);
}
 
開發者ID:sdrausty,項目名稱:buildAPKsSamples,代碼行數:18,代碼來源:DictionaryProvider.java

示例2: getSuggestions

private Cursor getSuggestions(String query) {
  query = query.toLowerCase();
  String[] columns = new String[] {
      BaseColumns._ID,
      DictionaryDatabase.KEY_WORD,
      DictionaryDatabase.KEY_DEFINITION,
   /* SearchManager.SUGGEST_COLUMN_SHORTCUT_ID,
                    (only if you want to refresh shortcuts) */
      SearchManager.SUGGEST_COLUMN_INTENT_DATA_ID};

  return mDictionary.getWordMatches(query, columns);
}
 
開發者ID:sdrausty,項目名稱:buildAPKsSamples,代碼行數:12,代碼來源:DictionaryProvider.java

示例3: getSuggestions

private Cursor getSuggestions(String query) {
  if (query.length() < 3) {
    return null;
  }

  boolean haveArabic = false;
  if (QuranUtils.doesStringContainArabic(query) &&
      QuranFileUtils.hasTranslation(getContext(), QURAN_ARABIC_DATABASE)) {
    haveArabic = true;
  }

  boolean haveTranslation = false;
  String active = getActiveTranslation();
  if (!TextUtils.isEmpty(active)) {
    haveTranslation = true;
  }

  int numItems = (haveArabic ? 1 : 0) + (haveTranslation ? 1 : 0);
  if (numItems == 0) {
    return null;
  }

  String[] items = new String[numItems];
  if (haveArabic) {
    items[0] = QURAN_ARABIC_DATABASE;
  }

  if (haveTranslation) {
    items[numItems - 1] = active;
  }

  String[] cols = new String[] { BaseColumns._ID,
      SearchManager.SUGGEST_COLUMN_TEXT_1,
      SearchManager.SUGGEST_COLUMN_TEXT_2,
      SearchManager.SUGGEST_COLUMN_INTENT_DATA_ID };
  MatrixCursor mc = new MatrixCursor(cols);

  Context context = getContext();
  boolean gotResults = false;
  for (String item : items) {
    if (gotResults) {
      continue;
    }

    Cursor suggestions = null;
    try {
      suggestions = search(query, item, false);
      if (suggestions != null && suggestions.moveToFirst()) {
        do {
          int sura = suggestions.getInt(1);
          int ayah = suggestions.getInt(2);
          String text = suggestions.getString(3);
          String foundText = context.getString(
              R.string.found_in_sura, QuranInfo.getSuraName(context, sura, false), ayah);

          gotResults = true;
          MatrixCursor.RowBuilder row = mc.newRow();
          int id = suggestions.getInt(0);

          row.add(id);
          row.add(text);
          row.add(foundText);
          row.add(id);
        } while (suggestions.moveToNext());
      }
    } finally {
      DatabaseUtils.closeCursor(suggestions);
    }
  }

  return mc;
}
 
開發者ID:Elias33,項目名稱:Quran,代碼行數:72,代碼來源:QuranDataProvider.java


注:本文中的android.app.SearchManager.SUGGEST_COLUMN_INTENT_DATA_ID屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。