标签:
public class MyButton extends Button
{
public MyButton(Context context , AttributeSet set)
{
super(context , set);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
{
super.onKeyDown(keyCode , event);
Log.v("-MyButton-" , "the onKeyDown in MyButton");
return false;
}
class MyActivity{
myButton.setOnKeyListener(new OnKeyListener()
{
@Override
public boolean onKey(View source
, int keyCode, KeyEvent event)
{
Log.v("-Listener-", "the onKeyDown in Listener");
}
return false;
}
});
public boolean onKeyDown(int keyCode, KeyEvent event)
{
super.onKeyDown(keyCode , event);
Log.v("-Activity-" , "the onKeyDown in Activity");
return false;
}
}
android系统最先触发的是按键上绑定的监听器
然后触发按键的回调
最后触发activity上的回调
标签:
原文地址:http://www.cnblogs.com/xuliangbk/p/4349529.html