Created
May 8, 2018 13:38
-
-
Save dmitriy-chernysh/77d70d66af52b65f61fbb81f9ff1a1f0 to your computer and use it in GitHub Desktop.
Android. Hide keyboard
This file contains hidden or 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
@Override | |
public void hideKeyboard() { | |
Activity activity = getActivity(); | |
if (activity == null) return; | |
View view = activity.getCurrentFocus(); | |
if (view != null) { | |
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); | |
if (imm != null) imm.hideSoftInputFromWindow(view.getWindowToken(), 0); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment