Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android EditText.setError not working in not focusable

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!

like image 902
Salva Triado Avatar asked Nov 09 '22 21:11

Salva Triado


1 Answers

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!

like image 86
Salva Triado Avatar answered Nov 14 '22 22:11

Salva Triado