您的位置:首页 > 其它

禁止Edittext弹出软件盘,光标依然正常显示

2016-05-30 22:11 295 查看
/**   * 禁止Edittext弹出软件盘,光标依然正常显示。   */  public void disableShowSoftInput()  {    if (android.os.Build.VERSION.SDK_INT <= 10)
{        editText.setInputType(InputType.TYPE_NULL);
}
else {
Class<EditText> cls = EditText.class;
Method method;              try {
method = cls.getMethod("setShowSoftInputOnFocus",boolean.class);
method.setAccessible(true);
method.invoke(editText, false);
}catch (Exception e) {          // TODO: handle exception        }                            try {
method = cls.getMethod("setSoftInputShownOnFocus",boolean.class);
method.setAccessible(true);
method.invoke(editText, false);
}catch (Exception e) {          // TODO: handle exception        }
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息