Skip to content

Instantly share code, notes, and snippets.

@Morteza-QN
Created January 13, 2022 07:20
Show Gist options
  • Save Morteza-QN/2f80756e898dd82228209135d932e69f to your computer and use it in GitHub Desktop.
Save Morteza-QN/2f80756e898dd82228209135d932e69f to your computer and use it in GitHub Desktop.
extension Function show and hide keyboard on view
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