In order to implement search with assistance from the Android system (to deliver search queries to an activity and provide search suggestions), your application must provide a search configuration in the form of an XML file.
This page describes the search configuration file in terms of its syntax and usage. For more information about how to implement search features for your application, begin with the developer guide about Creating a Search Interface .
- file location:
-
res/xml/ filename .xml
Android uses the filename as the resource ID. - syntax:
-
<?xml version="1.0" encoding="utf-8"?> < searchable xmlns:android="http://schemas.android.com/apk/res/android" android:label=" string resource " android:hint=" string resource " android:searchMode=["queryRewriteFromData" | "queryRewriteFromText"] android:searchButtonText=" string resource " android:inputType="
inputType
" android:imeOptions="imeOptions
" android:searchSuggestAuthority=" string " android:searchSuggestPath=" string " android:searchSuggestSelection=" string " android:searchSuggestIntentAction=" string " android:searchSuggestIntentData=" string " android:searchSuggestThreshold=" int " android:includeInGlobalSearch=["true" | "false"] android:searchSettingsDescription=" string resource " android:queryAfterZeroResults=["true" | "false"] android:voiceSearchMode=["showVoiceSearchButton" | "launchWebSearch" | "launchRecognizer"] android:voiceLanguageModel=["free-form" | "web_search"] android:voicePromptText=" string resource " android:voiceLanguage=" string " android:voiceMaxResults=" int " > < actionkey android:keycode="KEYCODE
" android:queryActionMsg=" string " android:suggestActionMsg=" string " android:suggestActionMsgColumn=" string " > </searchable> - elements:
- example:
-
XML file saved at
res/xml/searchable.xml
:<?xml version="1.0" encoding="utf-8"?> <searchable xmlns:android="http://schemas.android.com/apk/res/android" android:label="@string/search_label" android:hint="@string/search_hint" android:searchSuggestAuthority="dictionary" android:searchSuggestIntentAction="android.intent.action.VIEW" android:includeInGlobalSearch="true" android:searchSettingsDescription="@string/settings_description" > </searchable>