|
楼主 |
发表于 2015-9-24 13:50:33
|
显示全部楼层
这种方法应该不能在x5这里边写吧??
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
// TODO Auto-generated method stub
if(keyCode==KeyEvent.KEYCODE_BACK&&event.getRepeatCount()==0){
// event.startTracking();
Toast.makeText(this, "监听返回键BACK", Toast.LENGTH_SHORT).show();
dialog();
return false;
}else if(keyCode==KeyEvent.KEYCODE_MENU){
Toast.makeText(this, "监听菜单键MENU", Toast.LENGTH_SHORT).show();
return false;
}//由于HOME键为系统键,此处不能捕获,需要重写onAttachedToWindow()
else if(keyCode==KeyEvent.KEYCODE_HOME){
Toast.makeText(this, "监听主页键HOME", Toast.LENGTH_SHORT).show();
return false;
}
return super.onKeyDown(keyCode, event);
} |
|