android: Softkeyboard perform action when Done key is pressed
Try this
It works both for DONE and RETURN.
EditText editText= (EditText) findViewById(R.id.editText);
editText.setOnEditorActionListener(new EditText.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId,
KeyEvent event) {
if (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER
|| actionId == EditorInfo.IME_ACTION_DONE) {
// Do your action
return true;
}
return false;
}
});
Try this
editText.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if(actionId==EditorInfo.IME_ACTION_DONE){
//do something
}
return false;
}
});