How to make EditText not editable through XML in Android?

后端 未结 27 1808
梦谈多话
梦谈多话 2020-11-28 17:35

Can anyone tell me how to make an EditText not editable via XML? I tried setting android:editable to false, but

  1. it is de
相关标签:
27条回答
  • 2020-11-28 18:31

    I use EditText.setFocusable(false) and set true again if I want to edit.

    0 讨论(0)
  • 2020-11-28 18:32

    disable from XML (one line):

     android:focusable="false"
    

    re-enable from Java, if need be (also one line):

    editText.setFocusableInTouchMode(true);
    
    0 讨论(0)
  • 2020-11-28 18:32

    This combination worked for me:

    <EditText ... >
        android:longClickable="false"
        android:cursorVisible="false"
        android:focusableInTouchMode="false"
    </EditText>
    
    0 讨论(0)
提交回复
热议问题