Skip to content

Instantly share code, notes, and snippets.

@massimilianochiodi
Created April 15, 2022 08:51
Show Gist options
  • Save massimilianochiodi/b1657f92148e7886d733a0e877985aab to your computer and use it in GitHub Desktop.
Save massimilianochiodi/b1657f92148e7886d733a0e877985aab to your computer and use it in GitHub Desktop.
Hide keyboard ( java )
private static void hideKeyBoardMethod(final Context context, final View view) {
try {
view.post( () -> {
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
assert imm != null;
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
} );
} catch (Exception e) {
e.printStackTrace();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment