Android automatically turns on and off the soft keyboard

Source: Internet
Author: User

Now there is a need to say that you want to be able to automatically hide and open the soft keyboard, the scene is used in alert dialog has a text box, pop-up dialog at the same time automatically eject the keyboard, edit and click Finish to close directly. It is used in the following ways:

Inputmanager.showsoftinput (Tveditor, inputmethodmanager.show_forced);

If you use the parameter inputmethodmanager.show_implicit, you will not automatically eject the keyboard, but you cannot automatically turn off the keyboard after using show_forced, and you must press the back key.

Many of the auto-hide keyboard methods in vivo are OK, but Samsung does not have a way to do so, including not limited to the following ways:

(1) inputmanager.togglesoftinput (inputmethodmanager.show_implicit,inputmethodmanager.hide_implicit_only);

(2) Dialog.getwindow (). Setsoftinputmode (WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

(3) Dialog.getwindow (). Setsoftinputmode (WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);

(4) Inputmanager.hidesoftinputfrominputmethod (Tveditor.getwindowtoken (), 0);

(5) Inputmanager.hidesoftinputfrominputmethod (Dialog.getwindow (). Getdecorview (). Getwindowtoken (), 0);

Finally inadvertently Google to, as long as the toggle to use the OK, and then display the use

Inputmanager.togglesoftinput (inputmethodmanager.show_forced, 0);

Hide also use

Inputmanager.togglesoftinput (inputmethodmanager.show_forced, 0);

Currently testing Samsung and Vivo are OK.

Android automatically turns on and off the soft keyboard

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.