Created
August 4, 2017 07:17
-
-
Save francisnnumbi/5c709aeab1fc2427d7085424b4230b7b to your computer and use it in GitHub Desktop.
Do you want to hide your soft keyboard programmatically? For example, when you click a button or when you press ENTER (for single line editText).
This snippet method is all you need.
Call it and pass in any view available (layout, textView, editText, button,...)
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
private void hideKeyboard(View v) { | |
try { | |
InputMethodManager imm = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE); | |
imm.hideSoftInputFromWindow(v.getWindowToken(), 0); | |
} catch (Exception e) {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment