6
 <TextView
                    android:id="@+id/txtSender"
                    style="@android:style/TextAppearance.Small"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerVertical="true"
                    android:layout_marginTop="10dp"
                    android:background="@drawable/sender_bubble"
                    android:gravity="center_vertical"
                    android:maxEms="11"
                    android:paddingBottom="5dp"
                    android:paddingLeft="5dp"
                    android:paddingRight="15dp"
                    android:paddingTop="5dp"
                    android:text="1234567"
                    android:autoLink="all"
                    android:textColor="@color/color_black"
                    android:textIsSelectable="true"
                    android:visibility="visible" />

This is my textview in customcell. When i click on textview it is not allowing me to select the text in textview. It is working perfect in my xperia 4.2.2 but when i run the same code in device having version 4.4.4, it is not working.

NOTE : When i set the same android:textIsSelectable="true" property to the Textview which is not in Listview, it works fine in 4.4.4. Listview just move to bottom and resets to its original position within half of a second.

Beena
  • 2,334
  • 24
  • 50

3 Answers3

4

In my case it wasn't working because I had textView in xml layout with android:visibility="gone" property and made it visible later in adapter code. So, you need call this after you makes textview visible

textView.setTextIsSelectable(true); 
Georgy Gobozov
  • 13,633
  • 8
  • 72
  • 78
  • It works. However, not fully. It seems like you can select the text of TextView. But, the screen resizes and then the selected block disappears right away. So, It just changes the screen and that's it. You may need to prevent that changes or something. – c-an Dec 12 '18 at 10:44
1

Remove android:descendantFocusability="blocksDescendants"​ in the recyclerview or listview to prevent the blocking of selection

Also, change the textview layout width from match_parent to wrap_content to prevent the selectable text feature to be disabled when reusing the text cell.

Kit
  • 2,370
  • 13
  • 11
  • We are using `android:descendantFocusability="blocksDescendants"` for some. What is the alternative of line which will work with `textIsSelectable`? – Faisal Shaikh Jan 08 '19 at 17:12
-1

Remove the textIsSelectable, instead use:

android:inputType="textMultiLine"

The text will be selectable and editable.

Evan Langlois
  • 4,050
  • 2
  • 20
  • 18