Introduction to Android Display and hide IME keyboard usage

Source: Internet
Author: User

At some point, you need to force the hidden Android keyboard, such as the current keyboard is showing, this time click on the slide-side panel, you must force the hidden input keyboard. Common methods on the Internet are:

1, Inputmethodmanager IMM = (Inputmethodmanager) getactivity ()
. Getsystemservice (Context.input_method_service);
Imm.togglesoftinput (0, inputmethodmanager.hide_not_always);

This is to let the input method status reversal, if not currently displayed is displayed. If it is displayed, it is hidden. Therefore, it does not conform to the application scenario described in this article.

2, Imm.hidesoftinputfrominputmethod (Passwdedit.getwindowtoken (), 0);

This by myself on the android4.2 machine test invalid.

3, Imm.hidesoftinputfrominputmethod (Getactivity (). Getcurrentfocus (). Getwindowtoken (), 0);

After I test, still invalid. Uncle's, for this small function wasted Zajia two hours of time.

4,Imm.hidesoftinputfromwindow (Passwdedit.getwindowtoken (), 0);

After testing, this is the only effective method!

In addition, it was said that:

Inputmethodmanager IMM = (Inputmethodmanager) This
. Getsystemservice (Context.input_method_service);
Boolean isopen=imm.isactive ();
LOG.I (TAG, "imm.isactive () =" + IsOpen);

Use the above code to determine whether the current input keyboard pop-up visible, completely rip, IsOpen has been true. Hereby record.

Introduction to Android Display and hide IME keyboard usage

Related Article

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.