3

How to replace the search icon with text "Search" on soft keyboard.

<EditText 
android:imeOptions="actionSearch" />
Raviteja
  • 97
  • 3
  • 16

2 Answers2

5

Instead of using imeOptions use the following :-

<EditText android:imeOptions="actionSearch" 
         android:inputType="text"/>

For handling click listener do as follows :

editText.setOnEditorActionListener(new TextView.OnEditorActionListener() { 
@Override 
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    if (actionId == EditorInfo.IME_ACTION_SEARCH) {
        performSearch(); 
        return true; 
    } 
    return false; 
} }); 
Adarsh Yadav
  • 3,752
  • 3
  • 24
  • 46
1

Answer taken from this stackoverflow question.

Try to set

  • android:imeActionLabel in XML or
  • in java code with .setImeActionLabel()

editText.setImeActionLabel(getString(R.string.xxx), EditorInfo.IME_ACTION_SEARCH);

Community
  • 1
  • 1
Marko
  • 20,385
  • 13
  • 48
  • 64
  • Take a look at this [link](http://stackoverflow.com/questions/26299861/edittext-input-method-action-not-working-when-setting-imeactionlabel) for a possible solution. – Marko Aug 10 '15 at 08:36