I'm trying to change the soft keyboard 'Go' action on a Samsung S3 & S3 Mini (I think any Samsung) to 'Search' and have it perform certain actions onclick.
I have the following at the moment, which works on non Samsung devices:
searchText.setImeActionLabel("Search",EditorInfo.IME_ACTION_UNSPECIFIED);
searchText.setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_ENTER) {
startSearch();
return true;
}
return false;
}
});
Where searchText is my custom editText.
The custom editText has nothing too special in the XML. The following being the relevant parts:
android:singleLine="true"
android:imeActionLabel="Go"
But Samsung phones insist on having 'Next' and don't run my startSearch() function on click. Is there a way I can make this happen?
I think it doesn't work because you use android:imeActionLabel
and that only changes the text of the Button. Use android:imeOptions="actionDone"
to actually change the IME action