ListSelector applies to the entire list

Posted by jax on Stack Overflow See other posts from Stack Overflow or by jax
Published on 2010-02-02T11:02:26Z Indexed on 2010/04/28 9:53 UTC
Read the original article Hit count: 186

Filed under:

I have a simple list with a listselector like so.

<ListView android:id="@+id/list" android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:layout_below="@+id/round"
    android:listSelector="#99000000" android:clickable="true" android:cacheColorHint="#00000000" android:background="#00000000">
</ListView>

As you can see android:listSelector="#99000000" but the "black alpha" color is applied to the entire list, not the selected item.


So this is what I have now but the entire list still turns black

::listview_background.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:state_enabled="false" android:state_focused="true"
        android:drawable="@drawable/list_normal" />
  <item android:state_pressed="true"
        android:drawable="@drawable/list_pressed" />
  <item android:state_focused="true"
        android:drawable="@drawable/list_active" />
</selector>

::colors.xml

<resources>
    <drawable name="list_normal">#96FFFFFF</drawable>
    <drawable name="list_active">#66000000</drawable>
    <drawable name="list_pressed">#CA000000</drawable>
</resources>

::the xml tag in my list

android:listSelector="@drawable/listview_background"

© Stack Overflow or respective owner

Related posts about android