Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid - ListView Item not changing its state
    primarykey
    data
    text
    <p>I'm currently facing a problem with background drawables on ListView Items. I have a ListView XML, an Item XML, and a Drawable XML for the differents states that one item can have.</p> <p>The problem is that when I click or press one of the item nothing changes visually, but the click works because the onItemClick() method I overrided is called and its code executed... Its like I didn't set the @background parameter !</p> <p>layout/my_activity.xml (which contains the listview) :</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/background" android:orientation="vertical" &gt; &lt;include ... /&gt; &lt;include ... /&gt; &lt;View ... /&gt; &lt;ListView android:id="@+id/listViewPacks" android:layout_width="fill_parent" android:layout_height="fill_parent" android:divider="@color/blue_vdark" android:dividerHeight="2dp" &gt; &lt;/ListView&gt; &lt;/LinearLayout&gt; </code></pre> <p>layout/listview_item_a.xml :</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/listview_item_a_d" android:orientation="vertical" android:padding="5dp" &gt; &lt;TextView ... /&gt; &lt;TextView ... /&gt; &lt;TextView ... /&gt; &lt;/LinearLayout&gt; </code></pre> <p>drawable/listview_item_a_d.xml :</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;item android:state_selected="true"&gt;&lt;shape&gt; &lt;gradient android:angle="270" android:endColor="#bbbbbb" android:startColor="#e9e9e3" /&gt; &lt;/shape&gt;&lt;/item&gt; &lt;item android:state_enabled="true"&gt;&lt;shape&gt; &lt;gradient android:angle="270" android:endColor="#ecca2e" android:startColor="#f9f7c9" /&gt; &lt;/shape&gt;&lt;/item&gt; &lt;item&gt;&lt;shape&gt; &lt;solid android:color="@color/gray_dark" /&gt; &lt;/shape&gt;&lt;/item&gt; &lt;/selector&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload