、
-----------------------------------------verified-----------------------------------
public static void Closeboard (Context mcontext) {
Inputmethodmanager IMM = (inputmethodmanager) mcontext
. Getsystemservice (Context.input_method_service);
Imm.hidesoftinputfromwindow (Myedittext.getwindowtoken (), 0);
if (imm.isactive ())//is always true
Imm.togglesoftinput (Inputmethodmanager.show_implicit,
Inputmethodmanager.hide_not_always);
}
public static void Hidesystemkeyboard (Context Mcontext,view v) {
Inputmethodmanager IMM = (Inputmethodmanager) ((abstractmmtclientactivity) mcontext)
. Getsystemservice (Context.input_method_service);
Imm.hidesoftinputfromwindow (V.getwindowtoken (), 0);
}
--------------------------------------Reference------------------------------------------------
1. Useful functions for hiding soft keyboards are:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
它可以用来抑制键盘出现,除非用户接触了edittext区域。
2, you can force Android to hide the virtual keyboard, using the Inputmethodmanager method, call hideSoftInputFromWindow .
InputMethodManager imm =(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);
这样可以强制在任何条件下隐藏虚拟键盘。
3、
Inputmethodmanager IMM = (inputmethodmanager) getsystemservice (Context.input_method_service);
Get an example of Inputmethodmanager
if (imm.isactive ()) {
If you turn on
Imm.togglesoftinput (inputmethodmanager.show_implicit, inputmethodmanager.hide_not_always);
Turn off the soft keyboard, open the same method, this method is switched on and off state
}
------------------------------------------
Hide Soft Keyboard-possible
int flags = WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
GetWindow (). Addflags (flags);
--------------------------------------------
Under the OnClick event. The following methods are possible. (If the edittext loses focus/gets focus, no effect)
Inputmethodmanager im = (inputmethodmanager) getsystemservice (Context.input_method_service);
Im.hidesoftinputfromwindow (Getcurrentfocus (). Getapplicationwindowtoken (), inputmethodmanager.hide_not_always);
Keyboard--android Hidden System keyboard