What you will need and use.
-
InputMethodManager
- The InputMethodManager is a client side API that exists in each application context and manages interactions.
-
View
- Currently focused view.
Context
-
windowToken
-Get windowToken from the window containing your currently focused view.
Showing the keyboard β¬
private fun View.showKeyboard() {
val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0)
}
Hiding the keyboard β¬
private fun View.hideKeyboard() {
val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
imm.hideSoftInputFromWindow(windowToken, 0)
}
Have a question don't hesitate to ask.Have a good dayπor night.hideKeyboard()// end of post ,share away.
Top comments (0)