Android: Dialog box show soft keyboard automatically when focus is on an EditText not working

前端 未结 2 2046
耶瑟儿~
耶瑟儿~ 2020-12-11 21:03

Android: show soft keyboard automatically when focus is on an EditText

I\'ve read this post that automatically shows the virtual keyboard when a dialog box is shown.

2条回答
  •  余生分开走
    2020-12-11 21:45

    What you can do is try using postDelayed(Runnable) for EditText as below,

                    ettext.requestFocus();
                    ettext.postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            InputMethodManager keyboard = (InputMethodManager)
                            getSystemService(Context.INPUT_METHOD_SERVICE);
                            keyboard.showSoftInput(ettext, 0);
                        }
                    },200);
    

提交回复
热议问题