Last active
October 7, 2017 00:49
-
-
Save kwong93/3dcea9f4207a85842ada1bb1b680f798 to your computer and use it in GitHub Desktop.
Show or hide Android 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
public static void hideKeyboard(Context context, View view) { | |
getInputMethodManager(context).hideSoftInputFromWindow(view.getWindowToken(), 0); | |
} | |
public static void showKeyboard(Context context, View view) { | |
getInputMethodManager(context).showSoftInput(view, 0); | |
} | |
public static InputMethodManager getInputMethodManager(Context context) { | |
return (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment