We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 65cc707 commit dde7b21Copy full SHA for dde7b21
1 file changed
utilcode/src/main/java/com/blankj/utilcode/utils/KeyboardUtils.java
@@ -36,6 +36,19 @@ public static void hideSoftInput(Activity activity) {
36
View view = activity.getCurrentFocus();
37
if (view == null) view = new View(activity);
38
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
39
+ if (imm == null) return;
40
+ imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
41
+ }
42
+
43
+ /**
44
+ * 动态隐藏软键盘
45
+ *
46
+ * @param context 上下文
47
+ * @param view 视图
48
+ */
49
+ public static void hideSoftInput(Context context, View view) {
50
+ InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
51
52
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
53
}
54
0 commit comments