Android show softkeyboard with showSoftInput is not working?

后端 未结 12 2129
抹茶落季
抹茶落季 2020-12-28 13:49

I have created a trivial application to test the following functionality. When my activity launches, it needs to be launched with the softkeyboard open.

My code doe

12条回答
  •  庸人自扰
    2020-12-28 14:17

    Following worked for me:

        mEditTextStudy.requestFocus();
        mEditTextStudy.post(
                new Runnable() {
                    @Override
                    public void run() {
                        InputMethodManager imm =
                                (InputMethodManager)
                                        getActivity()
                                                .getSystemService(Context.INPUT_METHOD_SERVICE);
                        if (imm != null) {
                            imm.showSoftInput(mEditTextStudy, SHOW_FORCED);
                        }
                    }
                });
    

提交回复
热议问题