public void showKeyboard() { if(editText!=null){ //设置可获得焦点 editText.setFocusable(true); editText.setFocusableInTouchMode(true); //请求获得焦点 editText.requestFocus(); //调用系统输入法 InputMethodManager inputManager = (InputMethodManager) editText .getContext().getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.showSoftInput(editText, 0); } }
dialog.show(); new Handler().postDelayed(new Runnable() { @Override public void run() { dialog.showKeyboard(); } },200);