android中onKeyDown解析

boolean android.app.Activity.onKeyDown(int keyCode,KeyEvent event)

这个方法返回的是布尔值

public booleanonKeyDown (int keyCode, KeyEvent event)
Since: API Level 1

Called when a key was pressed down and not handled by any of the views inside of the activity.

当一个按键被按下时调用该方法并且不用处理这个activity内部的任何界面。

 So, for example, key presses while the cursor is inside a TextView will not trigger the event (unless it is a navigation to another object) because TextView handles its own key presses.

因此,例如,当光标停在一个TextView上面按键按下时不会触发这个事件(除非它是另一个对象的导航),因为TextView处理它自己的按键事件。

If the focused view didn't want this event, this method is called.

如果光标所在的视图不想这个事件,这个方法被调用。

The default implementation takes care of KEYCODE_BACK by callingonBackPressed(), though the behavior varies based on the application compatibility mode: forECLAIR or later applications, it will set up the dispatch to callonKeyUp(int, KeyEvent) where the action will be performed; for earlier applications, it will perform the action immediately in on-down, as those versions of the platform behaved.

默认通过调用onBackPressed()方法来负责实现KEYCODE_BACK,尽管行为变化基于应用程序的兼容模式:它将为ECLAIR或者更高版本的应用程序,在行动展现的地方设置调度去调用onKeyUp(int ,KeyEvent)方法;在更低的版本中,它将在按下按键之后立即展现这个动作,就像这些版本在这个平台上所展现的。

Other additional default key handling may be performed if configured withsetDefaultKeyMode(int).

其他另外的默认的按键如果用setDefaultKeyMode(int)方法配置,则它的处理可能会展现出来。

Parameters

参数

keyCode

The value in event.getKeyCode().

event.getKeyCode()方法中的值

event

Description of the key event.

按键事件的描述

Returns
  • Return true to prevent this event from being propagated further, orfalse to indicate that you have not handled this event and it should continue to be propagated.

如果阻止这个事件传播则返回true,如果表明你没有处理这个事件并且它应该继续被传播时返回false。

See Also

看其他方法:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值