当右下方箭头出现clic时,在视图寻呼机中,片段被更改。我想拦截此事件或从键盘上删除箭头。有可能吗?
我尝试使用onKeyUp和onKeyDown方法拦截keyevent,但它无法正常工作:
if (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_RIGHT || event.getKeyCode() == KeyEvent.KEYCODE_DPAD_LEFT) {
return true;
}
我的问题与here
相同答案 0 :(得分:4)
尝试使用dispatchKeyEvent(KeyEvent event)
:
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
Log.i("key pressed ", String.valueOf(event.getKeyCode()));
if(event.getKeyCode() == KeyEvent.KEY_A /*select required keycode*/ ){
// perform task
}
return super.dispatchKeyEvent(event);
}