给大家分享下隐藏整个界面软键盘的方法,如果大家有更好的方法也建议下,谢谢了

来源:互联网 发布:肥版国家地理知乎 编辑:程序博客网 时间:2024/05/22 00:51
public  static void hiddenKeyboard(Context context,ViewGroup root){    final int childCount = root.getChildCount();    for (int i = 0; i < childCount; ++i) {        final View child = root.getChildAt(i);        if(child instanceof EditText){            InputMethodManager imm = (InputMethodManager)context.getSystemService(                    context.INPUT_METHOD_SERVICE);            imm.hideSoftInputFromWindow(child.getWindowToken(), 0);        }        if (child instanceof ViewGroup) {            hiddenKeyboard(context,(ViewGroup) child);        }    }}
这是自己封装好的方法
0 0