Skip to content

Instantly share code, notes, and snippets.

@nichtemna
Created July 22, 2016 11:49
Show Gist options
  • Save nichtemna/ba8637f21da878e9077570f436fa4028 to your computer and use it in GitHub Desktop.
Save nichtemna/ba8637f21da878e9077570f436fa4028 to your computer and use it in GitHub Desktop.
Android toggle keyboard programmaticaly
public static void showKeyboard(Context context, View view) {
InputMethodManager inputMethodManager =(InputMethodManager)context.getSystemService(Activity
.INPUT_METHOD_SERVICE);
inputMethodManager.showSoftInputFromInputMethod(view.getWindowToken(), 0);
}
public static void hideKeyboard(Context context, View view) {
InputMethodManager inputMethodManager =(InputMethodManager)context.getSystemService(Activity
.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