Created
May 16, 2018 16:30
-
-
Save EmmanuelGuther/60443186eaa573a91e700429039973b1 to your computer and use it in GitHub Desktop.
Kotlin extension function to hide keyboard if it is being shown
This file contains hidden or 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
fun AppCompatActivity.hideKeyBoard(){ | |
val view = this.currentFocus | |
if (view != null) { | |
val inputMethodManager = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager | |
inputMethodManager.hideSoftInputFromWindow(view.windowToken, 0) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment