EditText打开输入框自动弹出软键盘方法

  • EditText 获取焦点后 直接弹出软键盘 利用定时器完美解决
  • 可以自由控制弹出的时间
 passwordInputView = dialogView.findViewById(R.id.pay_password);
                    passwordInputView.setFocusable(true);
                    passwordInputView.setFocusableInTouchMode(true);
                    passwordInputView.requestFocus();
                    Timer timer = new Timer();
                    timer.schedule(new TimerTask() {
                        public void run() {
                    InputMethodManager inputMethodManager =
                   (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                   inputMethodManager.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
                        }
                    }, 100);//这里的100是显示后多久弹出软键盘100=0.1/s

猜你喜欢

转载自blog.csdn.net/life_s/article/details/80443472