// 按键按下,所触发的事件 public boolean onKeyDown(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_DPAD_CENTER: display("中键被按下"); break; case KeyEvent.KEYCODE_DPAD_DOWN: display("下键被按下"); break; case KeyEvent.KEYCODE_DPAD_LEFT: display("左键被按下"); break; case KeyEvent.KEYCODE_DPAD_RIGHT: display("右键被按下"); break; case KeyEvent.KEYCODE_DPAD_UP: display("上键被按下"); break; } return super.onKeyDown(keyCode, event); } // 按键弹起,所触发的事件 public boolean onKeyUp(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_DPAD_CENTER: display("中键被弹起"); break; case KeyEvent.KEYCODE_DPAD_DOWN: display("下键被弹起"); break; case KeyEvent.KEYCODE_DPAD_LEFT: display("左键被弹起"); break; case KeyEvent.KEYCODE_DPAD_RIGHT: display("右键被弹起"); break; case KeyEvent.KEYCODE_DPAD_UP: display("上键被弹起"); break; } return super.onKeyUp(keyCode, event); }
// 按键按下,所触发的事件
public boolean onKeyDown(int keyCode, KeyEvent event) {
switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_CENTER:
display("中键被按下");
break;
case KeyEvent.KEYCODE_DPAD_DOWN:
display("下键被按下");
break;
case KeyEvent.KEYCODE_DPAD_LEFT:
display("左键被按下");
break;
case KeyEvent.KEYCODE_DPAD_RIGHT:
display("右键被按下");
break;
case KeyEvent.KEYCODE_DPAD_UP:
display("上键被按下");
break;
}
return super.onKeyDown(keyCode, event);
}
// 按键弹起,所触发的事件
public boolean onKeyUp(int keyCode, KeyEvent event) {
switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_CENTER:
display("中键被弹起");
break;
case KeyEvent.KEYCODE_DPAD_DOWN:
display("下键被弹起");
break;
case KeyEvent.KEYCODE_DPAD_LEFT:
display("左键被弹起");
break;
case KeyEvent.KEYCODE_DPAD_RIGHT:
display("右键被弹起");
break;
case KeyEvent.KEYCODE_DPAD_UP:
display("上键被弹起");
break;
}
return super.onKeyUp(keyCode, event);
}