我在我的活动中实现了dispatchKeyEvent来监听被按下的Enter键.问题是,当我点击回车时,它会调用我的方法两次?我怎样才能解决这个问题 ?谢谢,祝你有愉快的一天!
@Override
public boolean dispatchKeyEvent(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
enter();
return true;
}
return super.dispatchKeyEvent(e);
};
Run Code Online (Sandbox Code Playgroud)