Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 422
Axel Avatar asked Oct 05 '14 06:10

Axel


2 Answers

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.

like image 85
eddy Avatar answered Sep 27 '22 22:09

eddy


Use this one

  searchview.setImeOptions(EditorInfo.IME_ACTION_SEARCH);

Look at this Tutorial it will solve your second problem of the intent filter understanding Intent Filters

Hope it helps you.

like image 38
Abhishek Chaubey Avatar answered Sep 27 '22 22:09

Abhishek Chaubey