如何暂时关闭当前活动的android键盘

如何暂时关闭当前活动的android键盘,android,android-softkeyboard,android-keypad,Android,Android Softkeyboard,Android Keypad,我有一个带有各种EditText的表单和一个确认按钮, 我需要当用户单击确认当前使用的EditText时,键盘将立即关闭,但如果用户再次尝试编辑其中一个EditText,键盘将再次出现 如果不添加大量的代码线来分别控制每个EditText,我如何做到这一点 InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);

我有一个带有各种
EditText
的表单和一个确认按钮, 我需要当用户单击确认当前使用的
EditText
时,键盘将立即关闭,但如果用户再次尝试编辑其中一个EditText,键盘将再次出现

如果不添加大量的代码线来分别控制每个
EditText
,我如何做到这一点

 InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);
                //Find the currently focused view, so we can grab the correct window token from it.
 View view = getCurrentFocus();
//If no view currently has focus, create a new one, just so we can grab a window token from it
 if(view == null) {
    view = new View(this);
 }
inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);

这将关闭keybord,虽然我不确定键盘是否会为相同的编辑文本打开gain,但我没有尝试过。

只需使用InputMethodManager即可

这边

InputMethodManager imm = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);

完美的5分钟倒计时后我会接受你的回答。谢谢