解决方案:重写show方法在方法里调用输入键盘
@Override
public void show(@NonNull FragmentManager manager, @Nullable String tag) {
super.show(manager, tag);
showKeyboard();
}
public void showKeyboard() {
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
if (et_price != null) {
//设置可获得焦点
et_price.setFocusable(true);
et_price.setFocusableInTouchMode(true);
//请求获得焦点
et_price.requestFocus();
//调用系统输入法
InputMethodManager inputManager = (InputMethodManager) et_price
.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
if (inputManager != null) {
inputManager.showSoftInput(et_price, 0);
}
}
}
}, 200);
}
参考;Android中自定义的dialog中的EditText无法弹出输入法解决方案 - 移动开发 - 亿速云