如果是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 { Classcls = EditText.class; Method setShowSoftInputOnFocus; setShowSoftInputOnFocus = cls.getMethod("setShowSoftInputOnFocus", boolean.class); setShowSoftInputOnFocus.setAccessible(true); setShowSoftInputOnFocus.invoke(editText, false); } catch (Exception e) { e.printStackTrace(); } }