Java 怪异的if/else行为

Java 怪异的if/else行为,java,android,if-statement,Java,Android,If Statement,我正在尝试用软键盘来完成动作。我的代码是这样的 private TextView.OnEditorActionListener getDoneListener() { return new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {

我正在尝试用软键盘来完成动作。我的代码是这样的

    private TextView.OnEditorActionListener getDoneListener() {
    return new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                nextPage();
                return true;
            }
            else {
                return false;
            }
        }
    };
}
然而,即使IDE将“(actionId==EditorInfo.IME\u ACTION\u DONE)”计算为true,它也不会调用nextPage(),而是返回false。如果我像这样施展表情,效果很好

    private TextView.OnEditorActionListener getDoneListener() {
    return new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if ((boolean)(actionId == EditorInfo.IME_ACTION_DONE)) {
                processPayment();
                return true;
            }
            else {
                return false;
            }
        }
    };
}

你知道是什么原因造成的吗?

EditorInfo.IME\u ACTION\u DONE返回一个int,我相信这就是你需要施放的原因it@brad . 所以这是一个int==int比较,应该可以。我对此有点困惑。是不是内存问题==->是一个引用比较,即两个对象都指向同一个内存位置。equals()会解决这个问题吗?我在新地方不太会做java编程,所以有点麻烦。你也可以试试
EditorInfo.IME\u ACTION\u DONE==actionId
?另外,如果条件,可以尝试删除整个
条件,然后键入fresh?否则,这就难倒我了。