KeyboardView.OnKeyboardActionListener详解

android.inputmethodservice.KeyboardView.OnKeyboardActionListener

接口OnKeyboardActionListener在KeyboardView中定义,用于监听虚拟键盘事件。

在接口OnKeyboardActionListener中声明8个抽象方法

1.  void onPress(int primaryCode)

Called when the user presses a key. This is sent before the onKey is called. For keys that repeat, this is only called once.

Parameters:

  • primaryCode the unicode of the key being pressed. If the touch is not on a valid key, the value will be zero.

2.  void onRelease(int primaryCode)

Called when the user releases a key. This is sent after the onKey is called. For keys that repeat, this is only called once.

Parameters:

  • primaryCode the code of the key that was released

3.  void onKey(int primaryCode, int[] keyCodes)

Send a key press to the listener.

Parameters:

  • primaryCode this is the key that was pressed
  • keyCodes the codes for all the possible alternative keys with the primary code being the first. If the primary key code is a single character such as an alphabet or number or symbol, the alternatives will include other characters that may be on the same key or adjacent keys. These codes are useful to correct for accidental presses of a key adjacent to the intended key.

4.  void onText(CharSequence text)

Sends a sequence of characters to the listener.

Parameters:

  • text the sequence of characters to be displayed.

5.  void swipeLeft()

Called when the user quickly moves the finger from right to left.

6.  void swipeRight()

Called when the user quickly moves the finger from left to right.

7.  void swipeDown()

Called when the user quickly moves the finger from up to down.

8.  void swipeUp()

Called when the user quickly moves the finger from down to up.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值