Android: softkeyboard not showing up

前端 未结 5 468
灰色年华
灰色年华 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:17

    Sometimes you will need to post-delay showing keyboard command, so in my case, i did the following

    editText.postDelayed(new Runnable() {
            @Override
            public void run() {
                InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
            }
        }, 300);
    

提交回复
热议问题