更改标签时关闭Android软键盘

问题描述:

我在我的Android应用程序中使用TabHost。当用户更改为某个选项卡时,我想要关闭软键盘。更改标签时关闭Android软键盘

你尝试过:

开启:

inputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); 
// only will trigger it if no physical keyboard is open 
mgr.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT); 

要关闭

InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); 
mgr.hideSoftInputFromWindow(editText.getWindowToken(), 0); 

((InputMethodManager)GetSystemService(Context.InputMethodService)).ToggleSoftInput(ShowShoftInputFlags.None, HideSoftInputFlags.None); 
+1

添加一个解释将使答案,甚至更好。 – 2012-11-06 18:03:38