키보드를 숨기는 메소드

1
2
3
4
5
6
7
    private static void hideSoftKeyboard(Activity activity) {
        InputMethodManager inputMethodManager =
                (InputMethodManager) activity.getSystemService(
                        Activity.INPUT_METHOD_SERVICE);
        inputMethodManager.hideSoftInputFromWindow(
                activity.getCurrentFocus().getWindowToken(), 0);
    }
 
cs

 

null exception 방지

1
2
if (This.getCurrentFocus() != null)
            hideSoftKeyboard(This);
cs

 

+ Recent posts