if (android.os.Build.VERSION.SDK_INT <= 10) {
tvContent.setInputType(InputType.TYPE_NULL);
} else {
TorpedoTrackActivity.this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
try {
Class<EditText> cls = EditText.class;
Method setSoftInputShownOnFocus;
setSoftInputShownOnFocus = cls.getMethod("setShowSoftInputOnFocus", boolean.class);
setSoftInputShownOnFocus.setAccessible(true);
setSoftInputShownOnFocus.invoke(tvContent, false);
} catch (Exception e) {
e.printStackTrace();
}
}
//这种好使
evInput.setInputType(InputType.TYPE_NULL);
//activity 级别限制软键盘弹出
//失去焦点并不好使
evInput.clearFocus();
//也不好使
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(evInput.getWindowToken(),0);
editText禁止键盘弹出
最新推荐文章于 2023-06-08 17:22:13 发布