6

有没有办法在对话框出现时防止键盘自动出现。

这是我的对话框的代码

final Dialog dialog = new Dialog(this);
                    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                    dialog.setContentView(R.layout.shopping_cart_confirm_dialog);
                    TextView txtConfirmEmail = (TextView)dialog.findViewById(R.id.txtConfirmEmail);
                    ...
                    dialog.show();

非常感谢。

4

2 回答 2

19

试试这个

dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
于 2013-03-18T21:44:41.157 回答
0

使用InputMethodManager你应该能够隐藏键盘。

检查hideSoftInputFromWindow。它接受由返回的窗口令牌

View.getWindowToken()


InputMethodManager mgr=(InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
mgr.hideSoftInputFromWindow(dialog.getWindow().getWindowToken(), 0);
于 2013-03-18T21:46:06.233 回答