2

I'm using my own selector for my ListView, but the default is not used. How are you supposed to set the default background drawable? With the below code I'd expect all of my list rows to be blue until focused or pressed.

<?xml version="1.0" encoding="utf-8"?>
<selector
    xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:state_pressed="true" >
        <shape>
            <gradient
                android:startColor="#0266e9"
                android:endColor="#0484f2"
                android:angle="90" />

        </shape>
    </item>

    <item android:state_focused="true" >
        <shape>
            <gradient
                android:startColor="#bbccff"
                android:endColor="#dce4fd"
                android:angle="90" />                                
        </shape>
    </item>


    <item>        
        <shape>
            <solid android:color="#FF0000FF"></solid>
        </shape>
    </item>
</selector>
  • 1
    Did you ever find a resolution to this problem? I am having the exact same issue here: http://stackoverflow.com/questions/4730691/android-listview-state-list-not-showing-default-item-background – Unpossible Jan 19 '11 at 01:15

1 Answers1

0

Could be that the default (the blue) is not visible: http://developer.android.com/reference/android/graphics/drawable/StateListDrawable.html#attr_android:visible

According to the document the visibility is initially false.

C0deAttack
  • 24,419
  • 18
  • 73
  • 81
  • Hmm I just tried setting this to true: ` ` but it made it never show up. It was originally showing up when pressed. – SapphireSun Jan 11 '11 at 07:22