Search code examples
androidtextviewjquery-ui-selectable

Text select able but not editable in the textView


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"
            />

Solution

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