我想在AlertDialog解雇后隐藏软键盘,但它仍然可见.这是我的代码:
alert = new AlertDialog.Builder(MyActivity.this);
imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
alert.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
}
});
解决方法:
在Manifest xml中
android:windowSoftInputMode="stateAlwaysHidden"
It will automatically hide soft keyboard on Dismiss of
Dialog