zoukankan      html  css  js  c++  java
  • EditText点击出现光标但不弹出软键盘

    3.0以下版本可以用editText.setInputType(InputType.TYPE_NULL)来实现。或者设置editText.setKeyListener(null)来实现.

    3.0以上版本除了调用隐藏方法:setShowSoftInputOnFocus(false),由于是系统内部方法。无法直接调用,所以采用反射的方式来进行调用

     if (android.os.Build.VERSION.SDK_INT <= 10) {
                mEditText.setInputType(InputType.TYPE_NULL);
            } else {
                ElderLeaveActivity.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(mEditText, false);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
  • 相关阅读:
    JAVA变量的作用域
    SQLite
    ajax
    浏览器调试
    SQL链接
    Computer
    Sql知识点总结
    Web Socket
    秒杀
    副业
  • 原文地址:https://www.cnblogs.com/cxk1995/p/6376999.html
Copyright © 2011-2022 走看看