null keyevent and actionid = 0 in onEditorAction() (Jelly Bean / Nexus 7)

后端 未结 6 762
醉梦人生
醉梦人生 2020-12-03 10:18

I have an edit text which functions as a search box in my application. In Jelly Bean on my Nexus 7 when I type something into the text box which I am listening on and hit en

6条回答
  •  我在风中等你
    2020-12-03 10:55

    You dont discover the truth, if you customize return key. You need both set imeActionLabel and imeActionId in your layout. Such as:

    imeActionLabel="xxxx"
    imeActionId = "6"
    

    In your java code:

    @Override
    public boolean onEditorAction(TextView v, int actionId,  KeyEvent event) {
    if (actionId == EditorInfo.IME_ACTION_DONE) {
         doSomeThing();
         return true;
       }
    
        return false;
    }
    

    It will work fine.

提交回复
热议问题