Keyboardutils.java--android Keyboard Tool Class

Source: Internet
Author: User

1  Packagecom.xdsjs.save.utils;2 3 ImportAndroid.content.Context;4 ImportAndroid.view.inputmethod.InputMethodManager;5 ImportAndroid.widget.EditText;6 7 ImportJava.util.Timer;8 ImportJava.util.TimerTask;9 Ten /** One * Turn the soft keyboard on or off A  * -  * @authorXdsjs -  */ the  Public classKeyboardutils { -     /** - * Punch the soft keyboard -      * +      * @parammedittext Input Box -      * @paramMcontext Context +      */ A      Public Static voidOpenkeybord (FinalEditText Medittext,FinalContext Mcontext) { at  -         //You have to wait for the UI drawing to finish, and the code to open the soft keyboard will take effect, so set a delay -Timer timer =NewTimer (); -Timer.schedule (NewTimerTask () { - @Override -              Public voidrun () { inInputmethodmanager IMM =(Inputmethodmanager) Mcontext - . Getsystemservice (context.input_method_service); to imm.showsoftinput (Medittext, inputmethodmanager.result_shown); + imm.togglesoftinput (inputmethodmanager.show_forced, - inputmethodmanager.hide_implicit_only); the             } *}, 500); $     }Panax Notoginseng  -     /** the * Turn off the soft keyboard +      * A      * @parammedittext Input Box the      * @paramMcontext Context +      */ -      Public Static voidClosekeybord (EditText medittext, Context mcontext) { $Inputmethodmanager IMM =(Inputmethodmanager) Mcontext $ . Getsystemservice (context.input_method_service); -  -Imm.hidesoftinputfromwindow (Medittext.getwindowtoken (), 0); the     } -}

Keyboardutils.java--android Keyboard Tool class

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.