I\'m trying to implement the search dialog and I am unable to display the search from an Activity.
I have my main activity defined in my manifest file, this activity sho
You are missing tag in your activity tag in manifest. replace your activity declaration by following.
<activity
android:name=".MenuListActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data
android:name="android.app.default_searchable"
android:value=".SearchActivity" />
</activity>
I've done all that but still cannot see the search dialog on API 17. It works however after adding
android:actionViewClass="android.widget.SearchView"
in the fragment menu
<item
android:id="@+id/menu_item_search"
android:actionViewClass="android.widget.SearchView"
android:icon="@android:drawable/ic_menu_search"
android:showAsAction="ifRoom"
android:title="@string/search"/>
did you check your res/xml/searchable.xml?
<?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:hint="@string/search_hint"
android:label="@string/search_label">
</searchable>
Search dialog doesn't show up when you have hard coded strings for hint and label. They have to be @string resources.
Also, there is no need to call or override the onSearchRequested() method in your calling activity unless you want to invoke search from one of your UI widgets like a Button or a ListItem.
Apart from declaring the SearchActivity in the manifest file you need to include the meta-data info.
If you want to invoke the search dialog throughout the application then include
<meta-data android:name="android.app.default_searchable"
android:value=".SearchActivity" />
inside the application tag.
If you want to invoke the search dialog only in a particular activity then include
<meta-data android:name="android.app.default_searchable"
android:value=".SearchActivity" />
inside the activity tag.
for more details please refer http://developer.android.com/guide/topics/search/search-dialog.html.