"Xfeng Android Development note" How to prevent the system from bringing up the keyboard pop-up but the cursor is still in the EditText

Source: Internet
Author: User

Online and many methods, all failed, and finally found the following methods:

//Hide System Keyboard     Public voidHidesoftinputmethod (EditText ed) {GetWindow (). Setsoftinputmode (WindowManager.LayoutParams.SOF        T_input_state_always_hidden); intCurrentVersion =Android.os.Build.VERSION.SDK_INT; String MethodName=NULL; if(CurrentVersion >= 16) {            //4.2MethodName = "Setshowsoftinputonfocus"; } Else if(CurrentVersion >= 14) {            //4.0MethodName = "Setsoftinputshownonfocus"; }        if(MethodName = =NULL) {ed.setinputtype (inputtype.type_null); } Else{Class<EditText> cls = EditText.class;            Method Setshowsoftinputonfocus; Try{Setshowsoftinputonfocus=Cls.getmethod (MethodName,Boolean.class); Setshowsoftinputonfocus.setaccessible (true); Setshowsoftinputonfocus.invoke (Ed,false); } Catch(nosuchmethodexception e) {ed.setinputtype (inputtype.type_null);            E.printstacktrace (); } Catch(illegalaccessexception e) {//TODO auto-generated Catch blockE.printstacktrace (); } Catch(IllegalArgumentException e) {//TODO auto-generated Catch blockE.printstacktrace (); } Catch(InvocationTargetException e) {//TODO auto-generated Catch blockE.printstacktrace (); }        }    }

"Xfeng Android Development note" How to prevent the system from bringing up the keyboard pop-up but the cursor is still in the EditText

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.