Skip to content Skip to sidebar Skip to footer

Make Android Textview Or Edittext Selectable

I want to make EditText or Textview selectable in my android project . project is for android 4.0+ . I add this : txtView.setTextIsSelectable(true) and also : txtView.setCustomSele

Solution 1:

<TextView
    android:id="@+id/id"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textIsSelectable="true"
    android:text="" />

*API Level 11 and up only

Solution 2:

setTextIsSelectable does fix the problem on Android 7.1.1 for sure. The setEnabled(false) and then true didn't work.

editText.setTextIsSelectable(true);

My exact situation was having setFocusable(false) and adding an onClickListener, then setting setFocusable(true) and onClickListener(null) gave me the error in the OP.

(not correct syntax but you get the idea)

Post a Comment for "Make Android Textview Or Edittext Selectable"