相关疑难解决方法(0)

dispatchKeyEvent调用方法两次

我在我的活动中实现了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)

java android

9
推荐指数
1
解决办法
5608
查看次数

标签 统计

android ×1

java ×1