I know that onTouchEvent() can return the current touch point's x,y in a view, However, when I touch a key on a softkeyboard. the method is not working,

My question is how can I apply onTouchEvent to softkeyboard on Android?

有帮助吗?

解决方案

It is not possible to get a touch event for a soft keyboard.

If you want to capture keys as they are entered into an EditText, check out the EditText.addTextChangedListener() function.

Alternatively, try implementing the View.OnKeyListener interface in your Activity, or overriding public boolean dispatchKeyEvent(KeyEvent e), or overriding public boolean onKeyDown(int keyCode, KeyEvent event). In all of those cases, you can check what the keyCode or KeyEvent is and handle it as you wish.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top