1

I need the softkeyboard to display the 'Done' key when inputting text into an EditText in my application. On an Android 2.1 device the 'Done' button is displayed, but not on 2.3 or it higher.

This is the code I use:

    e.setImeOptions(EditorInfo.IME_ACTION_DONE);

    e.setOnEditorActionListener(
            new EditText.OnEditorActionListener() {
                @Override
                public boolean onEditorAction(TextView v, int actionId,KeyEvent event) {
                    if (actionId == EditorInfo.IME_ACTION_SEARCH ||
                            actionId == EditorInfo.IME_ACTION_DONE ||
                            event.getAction() == KeyEvent.ACTION_DOWN &&
                            event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
                        Toast.makeText(getBaseContext(), e.getText().toString(), Toast.LENGTH_SHORT).show();

                        InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
                        imm.hideSoftInputFromWindow(e.getWindowToken(), 0);

                        return true;
                    }
                    return false;
                }
            });

I am using a samsung device with Android version 2.3.4.

Screenshort of the edittext:

enter image description here

Marmoy
  • 8,009
  • 7
  • 46
  • 74
M.A.Murali
  • 9,988
  • 36
  • 105
  • 182
  • 1
    instead of done the enter key will do the same work. – Padma Kumar Nov 29 '11 at 08:32
  • Does the answer to [this question](http://stackoverflow.com/questions/5372833/how-do-i-get-the-done-button-to-appear-on-the-soft-keyboard) help? It suggests that you should flip on the single line flag, but this may or may not work for your UI. – Alex Florescu Nov 29 '11 at 08:54

1 Answers1

2

It is not Android version's fault, but the IME your device use. Samsung (and some of HTC, I think) IME never change the letter to "Done" or "Next" or "Go".

Anh Tuan
  • 1,728
  • 1
  • 13
  • 25