Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selector requires drawable attribute?

Tags:

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.

like image 989
Garzahd Avatar asked Apr 03 '12 17:04

Garzahd


1 Answers

android:drawable="@color/red"

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

like image 65
Samir Mangroliya Avatar answered Oct 18 '22 02:10

Samir Mangroliya