Dismiss Android Soft Keyboard when changing Tabs
I'm usin开发者_开发百科g a TabHost in my Android Application. When a user changes to a certain tab, I would like to dismiss the soft keyboard.
Have you Tried:
To turn on:
inputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
// only will trigger it if no physical keyboard is open
mgr.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
To turn off
InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
mgr.hideSoftInputFromWindow(editText.getWindowToken(), 0);
((InputMethodManager)GetSystemService(Context.InputMethodService)).ToggleSoftInput(ShowShoftInputFlags.None, HideSoftInputFlags.None);
精彩评论