Searching For Food
Step #2: Integrate the Search in the Application.............................
Now we need to tell Android that this application is searchable and how to
do the search.
First, we need to overhaul our AndroidManifest.xml file to indicate that the
LunchList activity is both searchable and the activity to launch to conduct a
search:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="apt.tutorial"
android:versionCode="1"
android:versionName="1.0">
<application android:label="@string/app_name">
<activity android:name=".LunchList"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data android:name="android.app.searchable"
android:resource="@xml/searchable" />
<meta-data android:name="android.app.default_searchable"
android:value=".LunchList" />
</activity>
<activity android:name=".DetailForm">
</activity>
<activity android:name=".EditPreferences">
</activity>
</application>
</manifest>
The second
any local search requests. The android.app.searchable metadata element
names @xml/searchable as being the configuration details for the search
itself. So, add a LunchList/res/xml/searchable.xml file with the following
content:
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:label="@string/searchLabel"
android:hint="@string/searchHint" />