onKeyListener not working on virtual keyboard

前端 未结 6 960
南方客
南方客 2020-12-01 16:00

I don\'t understand why this piece of code is not working. Only backspace and return key are detected. Listener doesn\'t fire for any other key. My device is Nexus One.

6条回答
  •  生来不讨喜
    2020-12-01 16:34

    Referencing from:

    http://developer.android.com/reference/android/view/View.OnKeyListener.html

    View.OnKeyListener

    Class Overview Interface definition for a callback to be invoked when a hardware key event is dispatched to this view. The callback will be invoked before the key event is given to the view. This is only useful for hardware keyboards; a software input method has no obligation to trigger this listener.

    It seems OnKeyListener was designed for HARDWARE keys only!

提交回复
热议问题