android会阻止在dialog.show上显示键盘
问题描述:
有没有办法在对话框显示时防止键盘自动出现。android会阻止在dialog.show上显示键盘
这里是我的代码为我的对话框
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();
非常感谢。
答
试试这个
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
答
使用InputMethodManager你应该能够隐藏键盘。
检查hideSoftInputFromWindow。它接受由
View.getWindowToken()
InputMethodManager mgr=(InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
mgr.hideSoftInputFromWindow(dialog.getWindow().getWindowToken(), 0);
感谢很多:) – 2013-03-19 00:24:03
@让 - 弗朗索瓦·欢迎您返回windowtoken。请投票。谢谢 – 2013-03-19 00:38:26