android - 对话框关闭后隐藏软键盘

标签 android keyboard hide android-softkeyboard soft-keyboard

我想在 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);
    }
});

最佳答案

list xml

android:windowSoftInputMode="stateAlwaysHidden"

It will automatically hide soft keyboard on Dismiss of Dialog

关于android - 对话框关闭后隐藏软键盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11633792/

相关文章:

android - 如何获取项目ID以及android网格中的项目位置

c# - 如何在 C# 中使用 sendkeys 发送键盘组合 Shift+Win+LEFT?

html - 如何使用 css 通过 href#id 隐藏 anchor 标记

java - Activity 和 View 的 findViewById 的父类(super class)型

android - 通过 Google Play 分发 Android 应用程序并直接作为 .apk 文件

android - Paypal 基本访问身份验证中的 URL 无效

C#:如何将类属性公开给一个类而不公开给另一个类?

linux - 在 linux 脚本中使用 xte

objective-c - 查明给定字符是否表示为键盘上的物理键 (Mac OS X)

jquery - 单击图像时无法加载 div 中的隐藏内容