androidtextviewandroid-inputtype

How to set a Multiline-TextView non-editable


I have a TextView which is from inputType="textMultiLine". The problem is, when I click (and hold) in a free part of the TextView (a part where is no text), it presents me the option of pasting text in. And when I do so, it overwrites the existing text with the text in the clipboard. I don't want this behavior. What can I do to make the TextView non-editable?

this is the xml-Code:

<TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="1. Hello, Dies ist ein Beispielsatz. \n2. Dies ist der zweite Satz."
        android:textSize="20dp"
        android:inputType="textMultiLine"
        />

Note: If I remove the inputType="textMultiLine", the option of pasting text is no longer presented. But I want the TextView to be multiline.


Solution

  • Try this make you TextView to android:longClickable="false"

    <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="1. Hello, Dies ist ein Beispielsatz. \n2. Dies ist der zweite Satz."
            android:longClickable="false"
            android:textSize="20dp"
            android:inputType="textMultiLine"
            />