I have a very simple EditText, as follows:
<EditText
android:id="@+id/myedit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:maxLength="32"/>
In some validation code, I use Android's EditText.setError()
to show any validation errors. This works fine in OS 2.x but not on an OS 3.x device (Xoom) -- on the Xoom you can see the outline of the error popup but you cannot see the error text.
I'm guessing that the text is there, but it is invisible. How do I make it visible? I don't see an android:textColor
that would relate to error text.
Also, if the text is indeed invisible, then any ideas why 2.x behaves differently to 3.x -- seems like this would cause backward-compatibility problems.
Thanks.
If you want to change the text color of the error text view, then you should add this code in your theme files.
For v8:
For v11:
It looks like you can work around this problem by calling EditText.setError() with a SpannableStringBuilder object rather than a String.
For a more elegant solution try this one:
I had the same problem. In my case, I had applied the parent="android:Theme.Light" to values-V14/styles.xml. This made the EditText control to look like a control from android API 2.3.3 and below. But the error message text was all white and hence, was not visible. After some head scratching I figured this out.
Change the parent="android:Theme.Light" to parent="android:Theme.Holo.Light.NoActionBar" (what ever Holo theme). But in the EditText definition add
android:background="@android:drawable/edit_text"
My EditText looks like this
Use native parent theme for appropriate API level in your own customized style! "@android:style/theme.name".
Distinguish themes by Configuration qualifier:
http://code.google.com/p/android/issues/detail?id=22920