我试图实现可搜索的字典示例应用。 除非我尝试从全局搜索中提取结果,否则一切似乎都在起作用。 我试图遵循文档中描述的所有内容。
我的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>
当局,哑剧类型
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 :(得分:1)
一切都很好但我没有明确配置搜索设置以在搜索结果中显示可搜索的字典。一旦我补充说,一切正常。