Dialog中EditText获取焦点,并且自动弹出软键盘

Posted 放纵的卡尔

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Dialog中EditText获取焦点,并且自动弹出软键盘相关的知识,希望对你有一定的参考价值。

       //解决dilaog中EditText无法弹出输入的问题
        dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
        //弹出对话框后直接弹出键盘
        et_newReason.setFocusableInTouchMode(true);
        et_newReason.requestFocus();
        CmzStaffApplication.handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                InputMethodManager inputManager =(InputMethodManager) et_newReason.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
                inputManager.showSoftInput(et_newReason, 0);
            }
        }, 100);

 

以上是关于Dialog中EditText获取焦点,并且自动弹出软键盘的主要内容,如果未能解决你的问题,请参考以下文章