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: