Close/hide the Android Soft Keyboard with Kotlin
I'm trying to write a simple Android app in Kotlin. I have an EditText and a Button in my layout. After writing in the edit field and clicking on the Button, I want to hide the virtual keyboard. There is a popular question Close/hide the Android Soft Keyboard about doing it in Java, but as far as I understand, there should be an alternative version for Kotlin. How should I do it? I think we can improve Viktor's answer a little. Based on it's always attached to a view, there will be context, if there is context then there is InputMethodManager fun View.hideKeyboard() { val imm = context