How to change text color of popup error window for EditText?

In ICS, when using a theme based on android:Theme.Light , the text of the popup when using setError(...) is white, like the background.

I can fix this problem by adding <item name="android:textColorPrimaryInverse">#ff000000</item> to my topic. While this helps, I'm a little worried that by changing some other text that uses textColorPrimaryInverse , it will turn from white to black and may not be visible. I would rather just change this attribute for EditText , which displays a popup , or just for this activity.

Lightening

I would like to change a property, preferably a text color, a popup that displays an error message when the user types something wrong in the EditText .

+8
android android-edittext
source share
2 answers

You can do it as follows:

 editText.setError(Html.fromHtml("<font color='red'>Error Message!</font>")); 
+1
source share

In the code, use http://developer.android.com/reference/android/view/View.html#setBackgroundResource(int ) or http://developer.android.com/reference/android/view/View.html#setBackgroundColor ( int ). They belong to the View, but EditText inherits them. The second method is easier, the first is more consistent.

Edit: Oh, this is a more complicated question. Perhaps using EditText.setError (CharSequence error, Drawable icon), can you put the error text on the icon? You can set setBounds (Rect) for the icon, so it can be quite large. The icon may be the color you need.

But I use onKey, beforeTextChanged, onTextChanged and show my own error message as Toast. You can use the normal view for the toast.

0
source share

All Articles