17 lines
530 B
Kotlin
17 lines
530 B
Kotlin
package com.example.todoapp.utils
|
|
|
|
import android.app.Activity
|
|
import android.content.Context
|
|
import android.view.inputmethod.InputMethodManager
|
|
|
|
fun hideKeyboard(activity: Activity) {
|
|
val inputMethodManager =
|
|
activity.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
|
|
|
val currentFocusedView = activity.currentFocus
|
|
currentFocusedView?.let {
|
|
inputMethodManager.hideSoftInputFromWindow(
|
|
currentFocusedView.windowToken, InputMethodManager.HIDE_NOT_ALWAYS
|
|
)
|
|
}
|
|
} |