如何在Android上清除焦点并删除键盘? [英] How to clear focus and remove keyboard on Android?
问题描述
我有一个EditText控件.如果我点击它,则会弹出软键盘,但是当我按下"enter/ok/return"时,EditText控件仍然具有焦点,并且键盘向上.
如何关闭软键盘并从中移除焦点?
I have a EditText control.
If I tap it the softkeyboard will popup however when I press "enter/ok/return" then the EditText control it still has focus and the keyboard up.
How do I close the softkeyboard and remove focus from it?
推荐答案
您可以尝试对布局中的另一个元素进行 SetFocus()
.
You could try doing SetFocus()
on another element in your layout.
如果您在谈论键盘本身的输入/确定/返回"按钮,则可能必须在 EditText
控件上设置 KeyListener
知道何时在另一个元素上 SetFocus()
.
If you are talking about the "enter/ok/return" button on the keyboard itself you may have to set up a KeyListener
on the EditText
control in order to know when to SetFocus()
on another element.
这篇关于如何在Android上清除焦点并删除键盘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!