Expansion and unwinding of the "Android" keyboard

Source: Internet
Author: User

Keyboard expansion and unwinding is mainly used to class inputmethodmanager:http://developer.android.com/reference/android/view/inputmethod/inputmethodmanager.html

The approximate method is as follows:

1  Public voidHide_keyboard_from (Context context, view view) {2Inputmethodmanager Inputmethodmanager =(Inputmethodmanager) Context.getsystemservice (activity.input_method_service);3 Inputmethodmanager.hidesoftinputfromwindow (View.getwindowtoken (), inputmethodmanager.hide_not_always);4     }5     6  Public voidShow_keyboard_from (Context context, view view) {7Inputmethodmanager Inputmethodmanager =(Inputmethodmanager) Context.getsystemservice (activity.input_method_service);8 inputmethodmanager.showsoftinput (view, inputmethodmanager.show_implicit);9}

When you expand and close a method call, you are required to pass in the second parameter. There are roughly four types of the following:

1) Hide_implicit_only: Indicate thatthe soft input window should only be hidden if it is not explicitly shown by The user.

2) Hide_not_always:to indicate that the soft input window should normally is hidden, unless it was originally show N withSHOW_FORCED

3) show_forced: Indicate thatthe user have forced the input method open (such as by long-pressing menu) so it Shoul D not being closed until they explicitly do.

4) Show_implicit:indicate that's a implicit request to SHOW the input window, not as the result of a direct Request by the user.

1) and 2) are used to close the keyboard, 3) and 4 are used to expand the keyboard.

If the user is clicked on the input box pop-up keyboard, call 1) is not hidden, the system at this time to determine the user intentionally call the keyboard! Call 2) You can close the keyboard;

If the user is using 3) as a parameter to display the keyboard, then 1) and 2 can not hide the keyboard, you need to use the parameter 0, force hide all keyboard;

If the user is using 4) as a parameter to display the keyboard, then 1) and 2) are all able to hide the keyboard.

Summed up is: forced > Explicit > Implicit.

For the hidden keyboard, where 1) belongs to implicit,2) belongs to the explicit,0 is the force;

For the display keyboard, then 4) is the implicit, the input box outbound belongs to explicit,3) is the force;

Only hidden levels >= the expanded level to hide the keyboard.

Expansion and unwinding of the "Android" 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.