监听上下左右键


        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);
    }

转载于:https://my.oschina.net/u/861587/blog/157975

你可能感兴趣的:(监听上下左右键)