當dialog中包含EditeText的時候,假如當前軟鍵盤是彈出的狀態(tài),當dialog執(zhí)行dismiss()的時候該軟鍵盤并不會消失。如果需要軟鍵盤隱藏,重寫dismiss()方法

Screenshot_20180302-104014.png
@Override
public void dismiss() {
View view = getCurrentFocus();
if (view instanceof TextView) {
InputMethodManager mInputMethodManager = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
mInputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.RESULT_UNCHANGED_SHOWN);
}
super.dismiss();
}