Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
// In your Activity or Fragment create a function as:
fun View.hideKeyboard() {
val inputManager = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
inputManager.hideSoftInputFromWindow(windowToken, 0)
// suppose you have a button with an id your_button_id in XML file related to this Activity or Fragment, so, on button click event:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment