How to make an EditText selectable but not editable on Android Ice Cream Sandwich?

后端 未结 4 1639
甜味超标
甜味超标 2021-02-07 03:15

I have a ListView in Activity, and in each item , I insert an EditText for show my text. I need drag the handle to select text & copy the text, but can not edit text. On And

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-07 03:56

    I think you could override the onKeyDown() method, make it do nothing but return true. It should catch the keypresses from the keyboard and negate them before they can go into the text in the EditText.

    You might also try setting editable to false like this

    android:editable="false"
    

    on the EditText in your xml layout. However I am not certain if this will let you still highlight and copy, but it is worth a shot.

提交回复
热议问题