In some apps, when you click EditText, the keyboard comes up and there is a search button instead of the Enter button. I also want to implement it like this, but how can I implement the search button and know how it is pressed?
android android-softkeyboard
Go to layout xml
<EditText android:imeOptions="actionSearch"
android:inputType="text"/>
Please do this on EditText.
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;
}
});
You can process the search button in Java code like this.
© 2024 OneMinuteCode. All rights reserved.