editText禁止键盘弹出

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 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);

你可能感兴趣的:(Android)