How can I change the icon on the right of the search manager?
The default icon is a magnifier
, but I've seen an app that does display instead of an magnifier an "OK"!
For my needs, the magnifier icon is not so good.
I use the SearchManage开发者_JAVA技巧r
to display the history of typed words.
So a better icon is OK instead of a search icon.
Late to the party, but I have done this:
<?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:label="@string/app_name"
android:hint="@string/search_hint"
android:icon="@drawable/search_icon"
android:searchButtonText="@string/ok_string">
</searchable>
Using the 'searchButtonText' attribute you can replace the default icon with your own text. The documentation is here: http://developer.android.com/guide/topics/search/searchable-config.html
What you won't find in the documentation is that you MUST use a string defined in your string resources, as shown above.
You can NOT do like this android:searchButtonText="OK"
Although documentations said it is deprecated and that the default icon is used, its still worth a shot. Try to do the following.
Corresponding with what you had in your comment regarding meta-data
and supplying your own XML resource file for searches.
searchable.xml
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:icon="@drawable/your_OK_image"
android:label="@string/search_label"
android:hint="@string/search_hint" >
</searchable>
精彩评论