Android EditText.setError not working in not focusable

1.6k Views Asked by At

How can I display a text error with setError in an EditText not focusable? It's important that users don't modify this EditText, it'll be modified for the application. Maybe I have another option different than focusable=false?

Now, I have it:

<EditText
    android:id="@+id/date"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:clickable="true"
    android:ems="10"
    android:focusable="false"
    android:inputType="text"
    android:onClick="onClick" />

Thanks a lot!

2

There are 2 best solutions below

0
On

Just use TextView and if you have an error somewhere then show image with drawableRight. Here's the example of doingit programmatically: https://stackoverflow.com/a/7380789/3864698

0
On

Finally I think it's not possible to do... Because the first necessity is to block the text, doing it with focusable=false or with a TextView, and it also blocks the functionality setError.

An editText with focusable = false I can get a right drawable (the default red exclamation mark) but without text. For this reason I finally added the text with a Toast.

It's not completelly that I wanted, but it's the most similar.

Thanks for your help!