Created
January 13, 2022 07:20
-
-
Save Morteza-QN/2f80756e898dd82228209135d932e69f to your computer and use it in GitHub Desktop.
extension Function show and hide keyboard on 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(isShow: Boolean) { | |
val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager | |
if (isShow) { | |
if (requestFocus()) imm.showSoftInput(this, 0) | |
} else { | |
imm.hideSoftInputFromWindow(windowToken, 0) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment