Android開発の道-----------ソフトキーボードの非表示とポップアップ

/**
 * 隐藏软键盘
 * @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);
    }
}

 

おすすめ

転載: blog.csdn.net/z1455841095/article/details/107788697