Created
November 17, 2017 12:02
-
-
Save smyykb/33d7a750529d0a596be1056a379cd213 to your computer and use it in GitHub Desktop.
Just for self-references
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
/** | |
* Utility method for showing keyboard. | |
* | |
* @param view which has keyboard focus | |
*/ | |
public static void showKeyboard(View view) { | |
final InputMethodManager inputMethodManager = (InputMethodManager) | |
view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); | |
inputMethodManager.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT); | |
} | |
/** | |
* Utility method for hiding keyboard. | |
* | |
* @param view which has keyboard focus | |
*/ | |
public static void hideKeyboard(View view) { | |
final InputMethodManager inputMethodManager = (InputMethodManager) | |
view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); | |
inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment