Erbez
Erbez

Reputation: 321

Disable user input in EditText but allow input programmatically

Is there a way to disable the option for the user to input text but allow the system to put some text in an EditText?

The onFocus method brings up a calendar, I need that function to be avaialable, so I think the EditText to still be enabled.

Upvotes: 1

Views: 218

Answers (1)

TheWanderer
TheWanderer

Reputation: 17824

Instead of fooling around with EditText, why not just use the View that already does what you want: the TextView?

You can define one in XML like so, so it visually responds to touches:

<TextView
    android:id="@+id/some_id"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:clickable="true"
    android:focusable="true"
    android:background="?android:selectableItemBackground"
/>

Upvotes: 2

Related Questions