EditText etv = dialog.findViewById(R.id.etv);
// 自动弹出键盘
etv.setFocusable(true);
etv.setFocusableInTouchMode(true);
etv.requestFocus();
// dialog 是现实在手机最顶层的view,在此基础上获取window,并弹出键盘
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
网友评论