Android – Selector requires drawable attribute

android

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true"
          android:color="#ff0000"/> 
    <item android:state_focused="true"
          android:color="#0000ff"/>
    <item android:color="#00ff00"/>
</selector>

I have this selector which I'm trying to use to change the background of a Linearlayout. Whenever I try to apply it, however I always get this error message:

org.xmlpull.v1.XmlPullParserException: Binary XML file line #4: tag requires a 'drawable' attribute or child tag defining a drawable

Obviously, it want me to use the drawable attibute but I'm not sure how to do that and change the background like I want to.

Best Answer

android:drawable="@color/red"

and add this in every item with diffrent color....

Related Topic