Nemo
Nemo

Reputation: 1079

Android keyboard "Go" button to "Search"

can any one tell how to get "Search" in place of "Go" or "Done" button in android keyboard. (not magnifying glass ) .

Upvotes: 8

Views: 22841

Answers (4)

Piash Sarker
Piash Sarker

Reputation: 103

Add below two line in your EditText tag :

 android:inputType="text"
 android:imeOptions="actionSearch"

And Add the setOnEditorActionListener() method to editText as below:

  etSearch.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                if(actionId == EditorInfo.IME_ACTION_SEARCH){
                     doSearch(); //Do whatever you intend to do when user click on search button in keyboard.
                   }

                    return true;
                }
                return false;
            }
        });

Upvotes: 1

nacho
nacho

Reputation: 591

Try this:

 <EditText
    android:id="@+id/editTextSearch"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:ems="10"
    android:imeOptions="actionSearch"
    android:singleLine="true" >
 </EditText>

Add "android:singleLine" to work properly

Upvotes: 4

NSjonas
NSjonas

Reputation: 12032

Try myEditText.setImeActionLabel("Search",EditorInfo.IME_ACTION_UNSPECIFIED). IME_ACTION_UNSPECIFIED allows you to put whatever text you want in the button.

Upvotes: 12

Samuel
Samuel

Reputation: 9993

something like this

android:imeOptions="actionSearch"

might work. in your case

there are also other options like

android:imeActionLabel="Search"

EDIT

please check this thread as well. LINK

accroding to the above link you get full text only in landscape mode.

full label is only displayed when the IME has a large amount of space for it (such as when the standard keyboard is in fullscreen mode).

so i guess you can use android:imeOptions="actionSearch" and the text Search will appear in landscape only.

Upvotes: 19

Related Questions