1

I want the text in the textView select able, copy able but not paste or writable. I want to prevent user writing or pasting over the existing text. How can I do that?

I have used the following code in the xml but it doesn't serve the purpose.

     <TextView
            android:id="@+id/text_body_story"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="text_body_story"
            android:inputType="textMultiLine"
            android:scrollHorizontally="false"
            android:textSize="14sp"
            android:textColorHighlight="#ffee04"
            android:textIsSelectable="true"
            android:longClickable="true"
            android:padding="10dp"
            android:layout_marginBottom="10dp"
            />
abc
  • 275
  • 3
  • 11
  • What doesn't work? – kabuko Mar 01 '18 at 23:03
  • If I enable text selectable then it is copyable and editable (user can write whatever he wishes; though it vanishes when activity closes) . But I want that a user can only select and copy the text but not edit or write. –  Mar 01 '18 at 23:07

2 Answers2

2

Delete the android:inputType attribute from your TextView. Having an input type is what's allowing the user to modify the text.

Ben P.
  • 52,661
  • 6
  • 95
  • 123
0

Try this

android:inputType="none"