'On Editor Action Listener doesn't work on Android

I need to override the work of the keyboard (Android), I write some code. At the onCreate method I write:

editNumber = findViewById(R.id.editNumber);
editNumber.setOnEditorActionListener(this);
editPassword = findViewById(R.id.password);
editPassword.setOnEditorActionListener(this);
editPassword.setOnTouchListener(
    View.OnTouchListener { view, event ->
        when (event.action) {
            MotionEvent.ACTION_DOWN -> {
                if (event.rawX >=
                        editPassword.right - resources.getDimension(R.dimen._48pxh)) {
                    editPassword.setTransformationMethod (
                        if (passwordVisible) null
                        else PasswordTransformationMethod());
                    passwordVisible = !passwordVisible;
                    editPassword.setSelection(password.size);
                }
                else {
                    editPassword.requestFocus();
                    super.onTouchEvent(event);
                }
            }
        }
    false;
});

I only init my view elements and add listeners. And override the method:

    override fun onEditorAction(view: TextView?, code: Int, event: KeyEvent?): Boolean {
        Log.d("My", "Sddfsd") //This log never write
        when (view.id) {
            R.id.editNumber -> {
                //I think its not matter what i do here for this question
                return true;
            }
            R.id.password -> {
                //I think its not matter what i do here for this question
                return true;
            }
        }
        return false;
    }

Logs show that the method onEditorAction never works. I try to use onKeyListner, but it doesn't work too, but its works with a physical keyboard from a PC. What am I doing wrong?



Solution 1:[1]

You should use addOnUnhandledKeyEventListener()

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Nls99912280