输入法服务中的警报对话框不专注于编辑文本



我正在尝试在输入方法服务中弹出警报对话框我在警报对话框中有一个编辑文本,它正在正确弹出,但编辑文本焦点上没有任何反应,请帮助我

 `AlertDialog.Builder builder = new AlertDialog.Builder(this);
 builder.setTitle("Make your selection");
 input = new EditText(this);
 input.setId(1);
 input.requestFocus();
 builder.setView(input);
 AlertDialog alert = builder.create();
 Window window = alert.getWindow();
 WindowManager.LayoutParams lp = window.getAttributes();
 lp.token = mInputView.getWindowToken();
 lp.type = WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;
 window.setAttributes(lp);
 window.addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
 alert.show();
 }`

我错过了什么吗?

正如你已经提到的requestfocus(),只需尝试添加以下行并尝试一次。因为它对我有用。

dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE|WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);

最新更新