在Android Pie 9.0中,编辑文本不可编辑

在Android Pie 9.0中,编辑文本不可编辑,android,android-layout,android-edittext,android-view,android-keypad,Android,Android Layout,Android Edittext,Android View,Android Keypad,各位好,, 我对AppCompatiEditText有问题。我已经覆盖了appcompatiedittext并在键盘上添加了Enter按钮(setImeOptions(EditorInfo.IME\u ACTION\u GO))。这在所有Android版本上都能正常工作,9.0除外。这是我们班的代码 public class EditTextWithGOButton extends AppCompatEditText { private EditTextAction editText

各位好,, 我对
AppCompatiEditText
有问题。我已经覆盖了
appcompatiedittext
并在键盘上添加了
Enter
按钮(
setImeOptions(EditorInfo.IME\u ACTION\u GO)
)。这在所有Android版本上都能正常工作,9.0除外。这是我们班的代码

 public class EditTextWithGOButton extends AppCompatEditText {

    private EditTextAction editTextAction;

    public interface EditTextAction {
        void onGoButtonClicked(String text);
    }

    public void setEditTextAction(EditTextAction editTextAction) {
        this.editTextAction = editTextAction;

    }

    public EditTextWithGOButton(Context context) {
        super(context);
        changeImeOption();
    }

    public EditTextWithGOButton(Context context, AttributeSet attrs) {
        super(context, attrs);
        changeImeOption();
    }

    public EditTextWithGOButton(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        changeImeOption();
    }

    private void changeImeOption() {
        this.setImeOptions(EditorInfo.IME_ACTION_GO);

    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if ((event.getAction() == KeyEvent.ACTION_DOWN) &&
                (keyCode == KeyEvent.KEYCODE_ENTER)) {
            if (editTextAction != null){

                editTextAction.onGoButtonClicked(getText().toString());

            }
        }
        // Returning false allows other listeners to react to the press.
        return false;

        // Handle all other keys in the default way
//        return super.onKeyDown(keyCode, event);
    }
}
还有我的XML

<com.app.common.views.EditTextWithGOButton
            android:id="@+id/edt_search_bar"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="3.2"
    android:background="@drawable/search_edittext_rounded_corner_background"
            android:drawableRight="@android:drawable/ic_menu_search"
            android:drawableTint="@color/colorPrimary"
            android:hint="@string/search_your_activity"
            android:paddingRight="10dp"
            android:paddingLeft="10dp"
            android:maxLines="1"
            android:paddingTop="05dp"
            android:paddingBottom="05dp"
            android:textColorHint="@color/colorPrimary" />


我已经厌倦了手动设置焦距。当我删除
this.setImeOptions(EditorInfo.IME\u ACTION\u GO)时
onKeyDown
listener,
AppCompatEditText
可编辑,但键盘不会弹出。我也试过编辑文本,但问题还是一样。任何解决方案???

我尝试了你的代码,在api 28上运行良好,键盘弹出,并且能够编写。问题是什么?@underoid你在Android Pie上试过了吗?是的,这是Pie 9.0。你找到解决方案了吗?请告诉我们解决方案。我试过你的代码,在api 28上运行良好,键盘弹出,并且能够写。有什么问题吗?@underoid你在Android Pie上试过了吗?是的,是Pie 9.0。你找到解决方案了吗?请告诉我们解决方案。