Soft keyboard shows Go button instead of Search button when entering some text into SearchView widget

I followed this tutorial to customize the search widget in the action bar. Almost everything works fine except that the right button is not displayed on the soft keyboard. Instead of showing a Search button, the keyboard shows a Go button and also wipes to another activity, and I'm pretty sure it can't be right.

enter image description here

Do you have an idea how to get the keyboard to show the Search button ? also why we should put this code in searchable actions:

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

      

Thanks in advance.

+3
android android-softkeyboard android-actionbar searchview


source to share


3 answers


It's pretty easy. However, I'm not sure why it doesn't show the correct button by default:

Anyway, here's what you need to do:

In your search config add this line:

android:imeOptions="actionSearch"

      



So, 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 this should fix your problem, but as I said before, I don't know why the "search" button is not showing to begin with.

+18


source to share


Use this

  searchview.setImeOptions(EditorInfo.IME_ACTION_SEARCH);

      



Take a look at this tutorial, it will solve your second problem of understanding Intent Filters

Hope this helps you.

+6


source to share


Try searching and calling the following method:

SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
searchView.setSubmitButtonEnabled(true);

      

+2


source to share







All Articles
Loading...
X
Show
Funny
Dev
Pics