展开全部
4.0以上的API禁止EditText弹出键盘需要这e68a8462616964757a686964616f31333332636334样写:
4.0的是setShowSoftInputOnFocus,4.2的是setSoftInputOnFocus。EditText editText;
//editText的实例化我不写了
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(e1.getWindowToken(), 0);
try {
Class cls = EditText.class;
setSoftInputShownOnFocus = cls.getMethod("setShowSoftInputOnFocus", boolean.class);
setSoftInputShownOnFocus.setAccessible(true);
setSoftInputShownOnFocus.invoke(editText, false);
} catch (Exception e) {
e.printStackTrace();
}
并且还要在配置文件里面加上android:windowSoftInputMode="stateHidden"
4.0以下的可用editText.setInputType(InputType.TYPE_NULL);
或者直接在XML进行属性设置。
如果对4.0以上系统的操作这句代码,EditText将会没有光标。