Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Close/Hide SoftinputKeyboard in kotlin [duplicate]

I have one button and edittext. I want to close my soft keyboard when user complete input in edittext and press button.

Or any guide or reference link for it.

like image 896
Rushabh Shah Avatar asked Jan 04 '23 01:01

Rushabh Shah


1 Answers

Call this function to hide the system keyboard:

fun View.hideKeyboard() {
    val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
    imm.hideSoftInputFromWindow(windowToken, 0)
}
like image 194
Sergei Emelianov Avatar answered Jan 05 '23 15:01

Sergei Emelianov