Android上对话框中不显示键盘
我有一个活动,点击按钮时会显示一个对话框。但键盘不会显示在对话框中。这是我的代码:Android上对话框中不显示键盘,android,Android,我有一个活动,点击按钮时会显示一个对话框。但键盘不会显示在对话框中。这是我的代码: final DialogComfigPass comfigPass = new DialogComfigPass(ActivityTable.this); comfigPass. getWindow (). clearFlags ( WindowManager . LayoutParams . FLAG_NOT_FOCUSABLE | WindowManager . LayoutParams . FLAG_ALT
final DialogComfigPass comfigPass = new DialogComfigPass(ActivityTable.this);
comfigPass. getWindow (). clearFlags ( WindowManager . LayoutParams . FLAG_NOT_FOCUSABLE | WindowManager . LayoutParams . FLAG_ALT_FOCUSABLE_IM );
comfigPass.show();`
**您必须像这样在对话框中打开键盘**
dialog.setOnShowListener(new OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
InputMethodManager inputMethodManager = (InputMethodManager)this.getSystemService(
Context.INPUT_METHOD_SERVICE);
inputMethodManager.toggleSoftInput(
InputMethodManager.SHOW_FORCED, 0);
}
});
**您必须像这样在对话框中打开键盘**
dialog.setOnShowListener(new OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
InputMethodManager inputMethodManager = (InputMethodManager)this.getSystemService(
Context.INPUT_METHOD_SERVICE);
inputMethodManager.toggleSoftInput(
InputMethodManager.SHOW_FORCED, 0);
}
});
试试这个,它会工作:)
comfigPass.getWindow().setSoftInputMode(LayoutParams.SOFT\u INPUT\u STATE\u VISIBLE);代码>尝试此方法它会起作用:)comfigPass.getWindow().setSoftInputMode(LayoutParams.SOFT\u INPUT\u STATE\u VISIBLE);代码>您可以使用setSoftInputMode(LayoutParams.SOFT\u INPUT\u STATE\u可见);代码>
// Show the keyboard when the dialog is displayed on the screen.
comfigPass.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
以前
comfigPass.show();
最后
final DialogComfigPass comfigPass = new DialogComfigPass(ActivityTable.this);
comfigPass. getWindow (). clearFlags ( WindowManager . LayoutParams . FLAG_NOT_FOCUSABLE | WindowManager . LayoutParams . FLAG_ALT_FOCUSABLE_IM );
comfigPass.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
comfigPass.show();`
您可以使用setSoftInputMode(LayoutParams.SOFT\u INPUT\u STATE\u可见);代码>
// Show the keyboard when the dialog is displayed on the screen.
comfigPass.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
以前
comfigPass.show();
最后
final DialogComfigPass comfigPass = new DialogComfigPass(ActivityTable.this);
comfigPass. getWindow (). clearFlags ( WindowManager . LayoutParams . FLAG_NOT_FOCUSABLE | WindowManager . LayoutParams . FLAG_ALT_FOCUSABLE_IM );
comfigPass.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
comfigPass.show();`
请使用
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
请使用
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
添加comfigPass.getWindow().setSoftInputMode(LayoutParams.SOFT\u INPUT\u STATE\u可见)代码>输入getDialog().getWindow().setSoftInputMode(LayoutParams.SOFT\u INPUT\u STATE\u可见)代码>为什么要回滚编辑?您最初的帖子几乎难以辨认。@Henry我猜他是新来的,在这里发布您的完整代码AddcomfigPass.getWindow().setSoftInputMode(LayoutParams.SOFT\u INPUT\u STATE\u VISIBLE)代码>输入getDialog().getWindow().setSoftInputMode(LayoutParams.SOFT\u INPUT\u STATE\u可见)代码>为什么要回滚编辑?你原来的帖子几乎难以辨认。@Henry我猜他是新来的,在这里发布你的完整代码集SOFT\u INPUT\u STATE\u ALWAYS\u VISIBLE
setSOFT\u INPUT\u STATE\u ALWAYS\u VISIBLE
给你的答案添加一些解释。给你的答案添加一些解释。