At present, a lot of input methods have automatic prompt completion function, in some application scenarios do not apply, need to disable the system input method, custom soft keyboard, edittext the cursor problem is more headache, online saying a lot, however, most of them can not solve the problem. The following is a demo I do for users reference.
Directly on the code:
XML Soft Keyboard:
<android.inputmethodservice.KeyboardView android:id= "@+id/keyboard_view" android:layout_width= "Fill_parent" android:layout_height= "Wrap_content" android:background= "@color/white" android:focusable= "true" android:focusableintouchmode= "true" android:keybackground= "@drawable/btn_keyboard_key" android:keytextcolor= "@color/black" &Nbsp; android:visibility= "Gone" />
Disable the system input method, solve the EditText cursor problem important code:
Public boolean ontouch (view v, motionevent event) {//Hide IME, display cursor edittext et= ( EditText) V;int intype = et.getinputtype (); // back up the input typeif (sdkint>=11) {Class<EditText> cls=EditText.class;try {Method Setshowsoftinputonfocus=cls.getmethod ("Setshowsoftinputonfocus", boolean.class); Setshowsoftinputonfocus.setaccessible (false); Setshowsoftinputonfocus.invoke (Et, false);} catch (nosuchmethodexception e) {e.printstacktrace ();} catch (illegalargumentexception e) {e.printstacktrace ();} catch (illegalaccessexception e) {e.printstacktrace ();} catch (invocationtargetexception e) {e.printstacktrace ();}} Else {et.setinputtype (Android.text.InputType.TYPE_NULL); // disable soft Inputet.setinputtype (Intype);} Keyboardutil=null;keyboardutil = new keyboardutil (Act, ctx, et); Et.ontouchevent (event);// call native handler// restore input typekeyboardutil.showkeyboard (); return true;}
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/79/FF/wKiom1agVz-SD7VTAAHFHD1np5c676.png "title=" 648282831665697547.png "alt=" Wkiom1agvz-sd7vtaahfhd1np5c676.png "/>
Other code is not affixed, need to complete the demo, please download it yourself.
This article is from the "11010803" blog, please be sure to keep this source http://11020803.blog.51cto.com/11010803/1737081
Android Andros Disable the system input method, customize the soft keyboard, solve the EditText cursor problem demo