androidandroid-virtual-keyboard

Keyboard hide event with BACK key


I've noticed in the Android Market Application, when you click over the search button, it shows the keyboard, but when you click the back button, the search EditText becomes invisible and the keyboard is hidden. The problem is that I can't hide the EditText after the keyboard is hidden after pressing the back key because I can't find a listener for hiding the keyboard event. I found this sample How to capture the "virtual keyboard show/hide" event in Android? but it doesn't work on the soft keyboard.


Solution

  • 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#onKeyPreIme(int, android.view.KeyEvent)