Created
October 12, 2017 20:13
-
-
Save MartuPuri/9acd0ac8b0479601c4e9fcf13cb2d623 to your computer and use it in GitHub Desktop.
Kotlin Extension - View
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
fun View.showKeyboard(context: Context) { | |
val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager | |
imm.showSoftInput(this, InputMethodManager.SHOW_FORCED) | |
} | |
fun View.hideKeyboard(context: Context) { | |
val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager | |
imm.hideSoftInputFromWindow(this.windowToken, 0) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment