2010-10-22 144 views
0

我試圖實現searchable字典示例應用程序。 除非我嘗試從全局搜索中獲取結果,否則一切似乎都正常。 我試圖遵循文檔中描述的所有內容。android全局搜索中未顯示搜索字典結果

我searchable.xml

<searchable xmlns:android="http://schemas.android.com/apk/res/android" 
     android:label="@string/search_label" 
     android:hint="@string/search_hint" 
     android:searchSettingsDescription="@string/settings_description" 
     android:searchSuggestAuthority="sd2.com.achie.DictionaryProvider" 
     android:searchSuggestIntentAction="android.intent.action.VIEW" 
     android:searchSuggestIntentData="content://sd2.com.achie.DictionaryProvider/dictionary" 
     android:searchSuggestSelection=" ?" 
     android:searchSuggestThreshold="1" 
     android:includeInGlobalSearch="true" 
     > 
</searchable> 

和當局MIME類型

public static String AUTHORITY = "sd2.com.achie.DictionaryProvider"; 
public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/dictionary"); 

public static final String WORDS_MIME_TYPE = ContentResolver.CURSOR_DIR_BASE_TYPE +"/vnd.sd2.com.achie"; 
public static final String DEFINITION_MIME_TYPE = ContentResolver.CURSOR_ITEM_BASE_TYPE +"/vnd.sd2.com.achie"; 

我的清單是

<!-- Receives the search request. --> 
    <intent-filter> 
     <action android:name="android.intent.action.SEARCH" /> 
     <!-- No category needed, because the Intent will specify this class component--> 
    </intent-filter> 

    <!-- Points to searchable meta data. --> 
    <meta-data android:name="android.app.searchable" 
       android:resource="@xml/searchable" />    

</activity> 
<!-- Displays the definition of a word. --> 
<activity android:name=".WordActivity" 
      android:theme="@android:style/Theme.NoTitleBar" /> 

<!-- Provides search suggestions for words and their definitions. --> 
<provider android:name=".DictionaryProvider" 
      android:authorities="sd2.com.achie.DictionaryProvider" /> 

<!-- Points to searchable activity so the whole app can invoke search. --> 
<meta-data android:name="android.app.default_searchable" 
      android:value=".SearchableDictionary" /> 

可能是什麼問題?

謝謝 的政績

+0

當您嘗試從全局搜索中提取結果時會發生什麼? – 2010-10-23 02:09:28

+0

它不顯示字典中的結果。我看不到我要出錯的地方如果你想檢查 – achie 2010-10-23 07:14:54

+0

,我可以把整個代碼發佈到某個地方試圖從全局搜索中抽取某些東西的代碼在哪裏? – 2010-10-25 17:43:55

回答

1

一切都很好,但我並沒有明確配置的搜索設置顯示在搜索結果中的搜索字典。一旦我補充說,一切工作正常。