search

Home  >  Q&A  >  body text

android - 怎样设置edittext只能响应ClickListener而不能输入

就像textview那样,因为我在recyclerview中用,有的能输入,有的不能输入
如果我设置setKeyListener(null),需要点击两次才响应点击事件,而不是点击就相应
如果设置setEnabled(false),点击都不会响应了
应该怎么弄啊

阿神阿神2772 days ago441

reply all(2)I'll reply

  • 怪我咯

    怪我咯2017-04-17 17:48:00

    Can be set in code

    editText.setFocusable(false);

    or set in XML

    android:focusable="false"

    That’s it, refer to How to make edit text not editable but clickable in JAVA

    Setting setEnabled(false) will call setClickable(false), so it cannot respond to click events

    reply
    0
  • 迷茫

    迷茫2017-04-17 17:48:00

    android:editable="false"

    reply
    0
  • Cancelreply