문제

I have a action bar search widget that offers search suggestion too. When the user types in a query and submits it or chooses a search suggestion, the keyboard doesn't disappear. How can I resolve this issue?

I haven't been able to figure out how to hide the keyboard upon search submit or suggestion choose.

Thank you.

도움이 되었습니까?

해결책

To hide the input method editor, use InputMethodManager:

  InputMethodManager imm=
      (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);

  imm.hideSoftInputFromWindow(v.getWindowToken(), 0);

You can use this from onEditorAction(), for example, as shown in this sample project.

다른 팁

I have just face to the same problem, and this way to hide keyboard after search

  @Override
 public boolean onQueryTextSubmit(String query) {
   searchView.clearFocus();
 return true;

}

GoodLuck !!

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top