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