I want to make a read-only EditText
view. The XML to do this code seems to be android:editable=\"false\"
, but I want to do this in code.
H
editText.setInputType(InputType.TYPE_NULL);
As per the docs this prevents the soft keyboard from being displayed. It also prevents pasting, allows scrolling and doesn't alter the visual aspect of the view. However, this also prevents selecting and copying of the text within the view.
From my tests setting setInputType
to TYPE_NULL
seems to be functionally equivalent to the depreciated android:editable="false"
. Additionally, android:inputType="none"
seems to have no noticeable effect.