键盘隐藏事件BACK键键盘、事件、BACK

2023-09-05 09:34:43 作者:东京雨季

我已经注意到了 Android Market的应用程序,当你点击了搜索按钮,它显示了键盘,但是当你点击返回按钮,搜索的EditText 成为无形和键盘是隐藏的,是我不能隐藏的问题在的EditText 后后pressing返回键的键盘被隐藏,因为我无法找到一个侦听器隐藏键盘事件。 我发现这个样本Howto捕捉虚拟键盘显示/隐藏事件的Andr​​oid? 但它不工作的软键盘上

I've noticed the Android Market Application, when you click over search button it shows the keyboard, but when you click the back button, the search EditText become invisible and the keyboard is hidden, the problem that I cant hide the EditText after the keyboard is hidden after pressing the back key, because i cant find a listener for hiding the keyboard event. I found this sample Howto capture the 'virtual keyboard show/hide' event in Android? but it doesnt work on soft keyboard

推荐答案

您需要实现这个捕捉BACK按钮之前被分派到IME:

You need to implement this to capture the BACK button before it is dispatched to the IME:

http://developer.android.com/reference/android/view/View.html#onKey$p$pIme(int, android.view.KeyEvent)