如何关闭幻灯片菜单上的键盘
How to close keyboard on slide menu
我使用 "Action bar Sherlock"。
我想要触摸屏幕并显示幻灯片菜单 "keyboard is closed"。
我对此很困惑。
我该怎么办?
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(0, 0);
试试这个隐藏键盘的方法
public void hideTypingKeyboard() {
try {
if(getCurrentFocus() != null) {
InputMethodManager imm = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
}
} catch (Exception e) {
e.printStackTrace();
}
}
编辑:
public static void hideEditTextKeyboard(InputMethodManager imm, EditText edittext) {
if (edittext != null) {
InputMethodManager imm = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(edittext.getWindowToken(), 0);
}
}
希望对您有所帮助!
我使用 "Action bar Sherlock"。 我想要触摸屏幕并显示幻灯片菜单 "keyboard is closed"。 我对此很困惑。 我该怎么办?
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(0, 0);
试试这个隐藏键盘的方法
public void hideTypingKeyboard() {
try {
if(getCurrentFocus() != null) {
InputMethodManager imm = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
}
} catch (Exception e) {
e.printStackTrace();
}
}
编辑:
public static void hideEditTextKeyboard(InputMethodManager imm, EditText edittext) {
if (edittext != null) {
InputMethodManager imm = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(edittext.getWindowToken(), 0);
}
}
希望对您有所帮助!