Created
April 9, 2021 19:25
-
-
Save userddssilva/2e5dcd1c0b0ef798ce639fe90c6531c5 to your computer and use it in GitHub Desktop.
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
// 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: | |
your_button_id.setOnClickListener{ | |
it.hideKeyboard() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment