Created
May 14, 2019 03:53
-
-
Save esabook/0679c78dfce3a3746c0d85ec30a34705 to your computer and use it in GitHub Desktop.
hide soft keyboard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @param v | |
*/ | |
public static void hideKeyboard(View v) { | |
if (v == null || v.getContext() == null) return; | |
InputMethodManager imm = (InputMethodManager) | |
v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); | |
if (imm != null && imm.isAcceptingText()) { | |
imm.hideSoftInputFromWindow(v.getRootView().getWindowToken(), 0); | |
} | |
} | |
/** | |
* @param a | |
*/ | |
public static void hideKeyboard(Activity a) { | |
hideKeyboard(a.getCurrentFocus()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment