Android development road----------- soft keyboard hiding and pop-up

/**
 * 隐藏软键盘
 * @param context
 */
public void hideInputWindow(Activity context){
    if(context==null){
        return;
    }
//判断软键盘是否开启
    final View v = ((Activity) context).getWindow().peekDecorView();
    if (v != null && v.getWindowToken() != null) {
        InputMethodManager imm = (InputMethodManager) context.getSystemService(context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
    }
}

 

Guess you like

Origin blog.csdn.net/z1455841095/article/details/107788697