Keyboard--android Hidden System keyboard

Source: Internet
Author: User

-----------------------------------------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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.