Skip to content

Commit dde7b21

Browse files
author
Blankj
committed
see 02/18 log
1 parent 65cc707 commit dde7b21

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

utilcode/src/main/java/com/blankj/utilcode/utils/KeyboardUtils.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,19 @@ public static void hideSoftInput(Activity activity) {
3636
View view = activity.getCurrentFocus();
3737
if (view == null) view = new View(activity);
3838
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+
if (imm == null) return;
3952
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
4053
}
4154

0 commit comments

Comments
 (0)