Skip to content

Instantly share code, notes, and snippets.

@laaptu
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save laaptu/bc9242423b4b01c30ba9 to your computer and use it in GitHub Desktop.
Save laaptu/bc9242423b4b01c30ba9 to your computer and use it in GitHub Desktop.
Hiding soft keyboard programmatically. The view passed should not be null and it doesn't matter that the view is to be the current edittext where there is focus. It can be any view until and unless it is present in the layout
public void hideSoftInputKeyBoard(View view) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null && view != null) {
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment