我有一个activity
,它打开一个dialog
,其中包含点击。只要dialog
打开softkeyboard
显示。我想阻止这一点。只有在dialog
中单击edittext
时,才会出现softkeyboard
。我使用的是Android 4.在Android 4.0中隐藏对话框中的软键盘加载
在此先感谢
我有一个activity
,它打开一个dialog
,其中包含点击。只要dialog
打开softkeyboard
显示。我想阻止这一点。只有在dialog
中单击edittext
时,才会出现softkeyboard
。我使用的是Android 4.在Android 4.0中隐藏对话框中的软键盘加载
在此先感谢
这应该是任何情况下:
public void hideKeyboard() {
mActivity.runOnUiThread(new Runnable() {
public void run() {
InputMethodManager inputManager = (InputMethodManager) mActivity
.getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.hideSoftInputFromWindow(mActivity
.getCurrentFocus().getWindowToken(),
InputMethodManager.HIDE_NOT_ALWAYS);
}
});
}
要做到这一点,设置软输入模式下,你叫dialog.Show之前():
// Build and create your dialog.
AlertDialog dialog = new AlertDialogBuilder(...).create();
// Hide soft keypad by default (will be displayed when user touches any edit field).
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
// Show the dialog.
dialog.show();
尝试[这](http://stackoverflow.com/a/11732587/1436931)你''清单文件 –
感谢在重播...对不起,它在对话框的情况下不工作 – Lincy