如果是android4.0以下,那么
editText.setInputType(InputType.TYPE_NULL);
就夠了,android4.0以上屏蔽軟鍵盤并且有光標,需要用到。
if (android.os.Build.VERSION.SDK_INT <= 10) {//4.0以下 danielinbiti editText.setInputType(InputType.TYPE_NULL); } else { this.act.getWindow().setSoftInputMode( WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); try { Class<EditText> cls = EditText.class; Method setShowSoftInputOnFocus; setShowSoftInputOnFocus = cls.getMethod("setShowSoftInputOnFocus", boolean.class); setShowSoftInputOnFocus.setAccessible(true); setShowSoftInputOnFocus.invoke(editText, false); } catch (Exception e) { e.printStackTrace(); } } 如有疑問請留言或者到本站社區交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
新聞熱點
疑難解答