Created
July 19, 2012 17:23
-
-
Save johnkil/3145466 to your computer and use it in GitHub Desktop.
The methods that opens and closes the 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
/** | |
* Shows the keyboard. | |
* | |
* @param view | |
*/ | |
public void showKeyboard(View view) { | |
Context context = view.getContext(); | |
InputMethodManager imm = (InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE); | |
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY); | |
} | |
/** | |
* Hides the keyboard. | |
* | |
* @param view | |
*/ | |
public void hideKeyboard(View view) { | |
Context context = view.getContext(); | |
InputMethodManager imm = (InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE); | |
imm.hideSoftInputFromWindow(view.getWindowToken(), 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment