NativeActivity的覆盖的onkeydown() [英] NativeActivity override onKeyDown()
问题描述
我具有我工作的一个 NativeActivity的
子类的问题,我的目标是捕获并处理来自Java code,而不是关键事件
本土code(这主要是由于因为这个),可惜我看不到日志()
present在的onkeydown
方法虽然的onCreate()
日志正在打印,我已经放在本地code日志版画为好。看来,的onkeydown
我的 NativeActivity的
的子类是永远不会被调用。
任何想法?
公共类CNativeActivity扩展NativeActivity的{
私人最终静态字符串变量=CNativeActivity; 保护无效的onCreate(捆绑savedInstanceState){
Log.v(TAG的onCreate);
super.onCreate(savedInstanceState);
} @覆盖
公共布尔的onkeydown(INT键code,KeyEvent的事件){
Log.v(TAG的onkeydown);
返回true;
}
}
补充工具KeyEvent.Callback
公共类@ @活动扩展NativeActivity的实现KeyEvent.Callback {
公共布尔onKeyMultiple(INT键code,诠释计数,KeyEvent的事件)
}
KeyEvent.Callback覆盖本地AInputEvent调度后虽然发生;所以基本上你必须忽略所有旧dipatching并实施一些新的东西,如果你想获得扩展键,如昆明,√,€,£...
I having problem with a NativeActivity
subclass I am working on, my goal would be to catch and handle key events from the Java code instead of
native code (this is mainly due because this), unfortunately I can not see the Log()
present in the onKeyDown
method though the
onCreate()
log is being printed and the log prints I have placed in the native code are as well. It seems that the onKeyDown
of my NativeActivity
subclass is never called.
Any idea?
public class CNativeActivity extends NativeActivity{
private final static String TAG = "CNativeActivity";
protected void onCreate(Bundle savedInstanceState) {
Log.v(TAG, "onCreate");
super.onCreate(savedInstanceState);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
Log.v(TAG, "onKeyDown");
return true;
}
}
add implements KeyEvent.Callback
public class @activity@ extends NativeActivity implements KeyEvent.Callback {
public boolean onKeyMultiple (int keyCode, int count, KeyEvent event)
}
KeyEvent.Callback overrides happen after the native AInputEvent dispatching though; so basically you'll have to ignore all old dipatching and implement something new if you want to get the extended keys like ÷,√,€,£, …
这篇关于NativeActivity的覆盖的onkeydown()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!