public class onKeyDownActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { // TODO Auto-generated method stub switch (keyCode) { /* 中间按键 */ case KeyEvent.KEYCODE_DPAD_CENTER: /* keyCode=23 */ Log.e("@@@@@@@@@@", "KEYCODE_DPAD_CENTER"); break; /* 上按键 */ case KeyEvent.KEYCODE_DPAD_UP: /* keyCode=19 */ Log.e("@@@@@@@@@@", "KEYCODE_DPAD_UP"); break; /* 下按键 */ case KeyEvent.KEYCODE_DPAD_DOWN: /* keyCode=20 */ Log.e("@@@@@@@@@@", "KEYCODE_DPAD_DOWN"); break; /* 左按键 */ case KeyEvent.KEYCODE_DPAD_LEFT: /* keyCode=21 */ Log.e("@@@@@@@@@@", "KEYCODE_DPAD_LEFT"); break; /* 右按键 */ case KeyEvent.KEYCODE_DPAD_RIGHT: /* keyCode=22 */ Log.e("@@@@@@@@@@", "KEYCODE_DPAD_RIGHT"); break; } return super.onKeyDown(keyCode, event); } }
只是个备忘录了,呵呵