In the layout set your input method options to search.
1 2 3 |
<EditText android:imeOptions="actionSearch" android:inputType="text" /> |
In the java add the editor action listener.
1 2 3 4 5 6 7 8 9 10 |
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; } }); |