Search code examples
androidandroid-actionbarandroid-softkeyboardsearchview

Soft keyboard shows a "Go" button instead of a "Search" button when entering some text in a SearchView widget


I have followed this tutorial to configure a searchview widget in the action bar. Almost everything works fine, except for the fact that the soft keyboard doesn't show the right button. Instead of showing a "Search" button the keyboard shows a "Go" button and it also takes me to another activity, which I'm sure it can't be right.

enter image description here

Do you have any idea how to make the keyboard show a "search" button? also why do we have to put this code in the searchable activities:

 <intent-filter>
        <action android:name="android.intent.action.SEARCH" />

Thanks in advance.


Solution

  • That's pretty easy. However, I'm not really sure why it doesn't show the right button by default:

    Anyway, here's what you need to do:

    In your searchable configuration add this line :

    android:imeOptions="actionSearch"
    

    So that you have something similar to this:

    <?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:imeOptions="actionSearch"/>
    

    I'm sure that should fix your problem, but as I mentioned I'm not sure why the "search" button isn't shown right from the start.