I need a multi-line EditText
where users can only select and copy text, but not edit it.
I tried this way:
<EditText
android:id="@+id/editTextHelp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionNext"
android:inputType="textMultiLine|none"
android:textIsSelectable="true"
android:minLines="3"
android:maxLength="2000"
android:scrollHorizontally="false" >
</EditText>
However, it seems like textMultiLine|none
doesn't work. How can I achieve what I want?
You can use TextView instead
<TextView
android:id="@+id/editTextHelp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textIsSelectable="true"
android:focusable="true"
android:longClickable="true"/>
You should use and TextView instead of EditText as following if its just for show some text:
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="none"
android:textIsSelectable="true"/>
But if you want to disable the textinput and maintain multi line perhaps you should try a programmatically approach like these:
editText.setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View view, int i, KeyEvent keyEvent) {
return true;
}
});
please read the documentation for more info
Try this
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="none"
android:textIsSelectable="true"
/>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.