Question

I just tried this example. I saved that code in res/color/hover.xml but I always get this error message and Eclipse won't compile my project with this xml. What am I doing wrong?

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
          android:color="#ffff0000"/> <!-- pressed -->
    <item android:state_focused="true"
          android:color="#ff0000ff"/> <!-- focused -->
    <item android:color="#ff000000"/> <!-- default -->
</selector> <!-- Error Message -->

Error parsing XML: not well-formed (invalid token) hover.xml /MmAndroid/res/color line 8 Android AAPT Problem

The only thing I might not have done is following. I don't know how to do that:

compiled resource datatype: Resource pointer to a ColorStateList.

Was it helpful?

Solution

you have to put this xml file inside the drawable folder. not in res/color

OTHER TIPS

How stupid, that they have such major mistakes in their examples on android.com!

It's not a mistake at-all. You can define selectors for text or for backgrounds. Lets say you want your text to be green, if state_check="true". What will you do then? Lay a background behind?

No. You will probably create an xml file with selectors for color-attributes. And reference textColor="@color/MYNEWCOLORXML" .... ét voilà.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top