自定义了Dialog然后弹出软键盘,但是键盘不属于当前活动窗口

代码如下
private View textEntryView;
AlertDialog myDialog = null;
private EditText post;

private void showMyDialog() {
LayoutInflater factory = LayoutInflater.from(this);
textEntryView = factory.inflate(R.layout.managerview, null);
textEntryView.findFocus();
myDialog = new AlertDialog.Builder(this).create();
myDialog.show();

myDialog.getWindow().setContentView(textEntryView);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
InputMethodManager imm = (InputMethodManager)
getSystemService(INPUT_METHOD_SERVICE);
imm.showSoftInput(textEntryView, 0); //显示软键盘
imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS); //显示软键盘


}


效果图:

自定义Dialog中得EditText弹出键盘

相关文章:

  • 2021-10-10
  • 2021-09-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-10
  • 2021-07-12
  • 2021-11-28
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-18
  • 2022-02-09
  • 2022-12-23
相关资源
相似解决方案