I am trying to get a login screen for an Android app and so far this is my code:
Just to add to Qianqian & peedee answers:
Here's the reason why the action id is EditorInfo.IME_ACTION_UNSPECIFIED (0) for any enter event.
actionId int: Identifier of the action. This will be either the identifier you supplied, or EditorInfo#IME_NULL if being called due to the enter key being pressed.
(Source: Android documentation)
So the proper way to handle enter key events would be:
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_NULL) {
// Handle return key here
return true;
}
return false;
}