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

前端 未结 2 1961
耶瑟儿~
耶瑟儿~ 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);
    
    0 讨论(0)
  • 2020-12-11 21:52

    Just try adding the below line before "et.setOnFocusChangeListener"

    ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE))
                        .showSoftInput(et, 2);
    
    0 讨论(0)
提交回复
热议问题