because the project to use a custom random keyboard, so you have to shield the system soft keyboard, but in the 4.0 test system, using the Edittext.setinputtype (Inputtype.type_null) method is able to hide the keyboard, However, the cursor is also hidden, so it cannot be used.
3.0 The following versions can be implemented with Edittext.setinputtype (Inputtype.type_null) . or set Edittext.setkeylistener (null) to implement. 3.0 or later in addition to calling the Hidden method Setshowsoftinputonfocus (false), because it is the internal method of the system, cannot be called directly, so it is called by reflection, as follows
In the project (the current project is using android4.0):
/span>
int sdk_int = android.os.build.version.sdk_int;if (sdk_int <= 10) {//click EditText, block default IME edittext.setinputtype ( Inputtype.type_null); EditText is the input text box for the declaration. } else {//click EditText, Hide System ime getwindow (). Setsoftinputmode (WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_ HIDDEN); try {class<edittext> cls = Edittext.class; method = Cls.getmethod ("Setshowsoftinputonfocus", boolean.class);//4.0 is Setshowsoftinputonfocus, 4.2 is setsoftinputshownonfocusmethod.setaccessible (false); Method.invoke (EditText, false); EditText is the input text box for the declaration. } catch (Nosuchmethodexception e) {e.printstacktrace ();} catch (IllegalArgumentException e) {e.printstacktrace ();} catch (Illegalaccessexception e) {e.printstacktrace ();} catch (InvocationTargetException e) {e.printstacktrace ()}}
Note:
The method of reflection above is found from the source code of TextView. Because EditText is inherited TextView, see the Internet is said to have the SDK inside is "Setsoftinputshownonfocus", anyway, specifically with their own SDK should be. 4.0 system corresponding to the set is setshowsoftinputonfocus, 4.2 system corresponding to the set is Setsoftinputshownonfocus, these two versions have been tested, is correctly available.
Reference:
Android Customizing the soft keyboard implementation
Android Customizing the soft keyboard
Android.edittext when Clicked , Hide System pop-up keyboard , display the cursor?
http://blog.163.com/[email protected]/blog/static/5550761120149684736794/
On Android, when you click EditText, hide the system soft keyboard and display the cursor