Android: softkeyboard not showing up

前端 未结 5 469
灰色年华
灰色年华 2021-01-18 17:16

I have 2 EditTexts in the MainActivity Layout. If i run the application normally the 1st EditText gets focused but the softkeyboard is not openned.

but when i used t

5条回答
  •  天涯浪人
    2021-01-18 18:18

        et2.clearFocus();
        et2.requestFocus();
        InputMethodManager mInputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        mInputMethodManager.showSoftInput(et2, InputMethodManager.SHOW_IMPLICIT);
    

    I meet the problem on Android N platform and resolve it by refocusing the editview. I don`t know the real reason why the editview should be cleared first,but it works fine for me.

提交回复
热议问题