Android imeOptions=“actionDone” not working

前端 未结 8 2088
无人及你
无人及你 2020-12-16 09:14

I am trying to get a login screen for an Android app and so far this is my code:



        
8条回答
  •  南笙
    南笙 (楼主)
    2020-12-16 09:48

    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;
    }
    

提交回复
热议问题