Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: Entire ListView changes color on focus, not just ListView child item
    primarykey
    data
    text
    <p>I am trying to apply a selector to a ListView to make it easy for those without touch screens to navigate my app. The thing is, by applying the selector to the ListView, it only seems to apply the background colors to the entire list, not the items inside of it.</p> <p><strong>Any ideas? Here's some code:</strong></p> <pre><code> &lt;ListView android:id="@android:id/list" android:layout_width="fill_parent" android:layout_height="fill_parent" android:listSelector="@drawable/listselector" /&gt; &lt;TextView android:id="@android:id/empty" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="There are no Clients yet." /&gt; </code></pre> <p><strong>listselector.xml in drawable folder:</strong></p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;selector android:id="@+id/myselector" xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;!-- Non focused states --&gt; &lt;item android:state_focused="false" android:state_selected="false" android:state_pressed="false" android:drawable="@color/darkblue" /&gt; &lt;item android:state_focused="false" android:state_selected="true" android:state_pressed="false" android:drawable="@color/green" /&gt; &lt;!-- Focused states --&gt; &lt;item android:state_focused="true" android:state_selected="false" android:state_pressed="false" android:drawable="@color/green" /&gt; &lt;item android:state_focused="true" android:state_selected="true" android:state_pressed="false" android:drawable="@color/green" /&gt; &lt;!-- Pressed --&gt; &lt;item android:state_pressed="true" android:drawable="@color/green" /&gt; &lt;/selector&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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