1

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?

Twentyonehundred
  • 2,199
  • 2
  • 17
  • 28

2 Answers2

1

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

0xDEADC0DE
  • 2,453
  • 1
  • 17
  • 22
  • Great! I had to set it to android:imeOptions="actionSearch" for it to display a search finder icon and run with my onClick function, but setting the imeOptions was definitely the answer, thanks! – Twentyonehundred Dec 19 '14 at 11:24
-1

Its not about any Samsung device. To achieve this, in your layout, just set the XML attributes android:imeOptions="actionNext" or android:imeOptions="actionDone" as per your requirement.
Please refer this link as well : http://developer.android.com/reference/android/widget/TextView.html#attr_android:imeOptions

Papershine
  • 4,995
  • 2
  • 24
  • 48
Deep Mehta
  • 1,237
  • 2
  • 11
  • 17