我想在关闭键盘时清除编辑文本的焦点,但是很遗憾,键盘上有一个我不知道keyEvent的键。有人可以澄清一下吗?
Here's the reference for the KeyEvent class.
编辑1: 这是我的代码:
holder.editText.setOnEditorActionListener { v, actionId, event ->
if(actionId == KeyEvent.KEYCODE_ENDCALL || actionId == KeyEvent.KEYCODE_BACK){
val imm = v.context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
imm.hideSoftInputFromWindow(v.getWindowToken(), 0)
v.clearFocus()
true
} else {
false
}
}