隐藏软键盘(Activity,Fragment通用)
作者:
椰子 | 来源:发表于
2018-05-17 10:38 被阅读15次/**
* 隐藏软键盘(可用于Activity,Fragment)
*/
fun hideSoftKeyboard(context: Context, viewList: List<View>?) {
if (viewList == null) return
val inputMethodManager = context.getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager
for (v in viewList) {
if (inputMethodManager.isActive(v)) {
inputMethodManager.hideSoftInputFromWindow(v.windowToken, InputMethodManager.HIDE_NOT_ALWAYS)
}
}
}
本文标题:隐藏软键盘(Activity,Fragment通用)
本文链接:https://www.haomeiwen.com/subject/qgtbdftx.html
网友评论