Frage

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?

War es hilfreich?

Lösung

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top