3

Here's a screenshot of my application. When the search box is clicked, the soft-keyboard automatically pops up, which is fine, but, if I also press the "Menu" button, the menu appears on top of the soft-keyboard.

How can I show the menu but collapse the SearchView if it is in focus and also hide the soft-keyboard. I probably need to check and do something in the onPrepareOptionsMenu method of my Activity, right?

It doesn't cause any real harm to me but it seems like an ugly implementation to the user when this happens.

enter image description here

Mridang Agarwalla
  • 43,201
  • 71
  • 221
  • 382

1 Answers1

0

You can call the getCurrentFocus() method from the searchView or override onWindowFocusChanged(boolean hasWindowFocus) in your activity.

If that view is the searchview, then you can close the keyboard in this way:

InputMethodManager imm = (InputMethodManager)getSystemService(
  Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(m_edittext.getWindowToken(), 0);
Myth1c
  • 639
  • 1
  • 7
  • 23