OnEditorActionListener not working

前端 未结 6 1341
心在旅途
心在旅途 2021-01-01 22:51

I simply want to catch the event when the user press enter on an editText.

I did not get the Toast message, not the \"Enter pressed\" and not the \"Some key pressed!

6条回答
  •  执念已碎
    2021-01-01 23:27

    myEditText.setOnEditorActionListener(new OnEditorActionListener() {
    
    public boolean onEditorAction(TextView arg0, int arg1, KeyEvent arg2) {
        Toast.makeText(getApplicationContext(), "some key pressed", Toast.LENGTH_LONG)
                            .show();
        return false;
    }
    });
    

    This code displays me some key pressed when pressed enter key after typing something in my edittext. But I don't know what is problem in your code.

提交回复
热议问题