Note that there are some explanatory texts on larger screens.

plurals
  1. POListView With Nine-Patch Item Background Issues
    primarykey
    data
    text
    <p><strong>WARNING: The XML in this question is wrong, read the answer before you confuse yourself!</strong></p> <hr> <p>I have been banging my head on the wall for a while now. The following posts have shed light on the subject, but failed to solve my issue: <a href="https://stackoverflow.com/questions/4730691/android-listview-state-list-not-showing-default-item-background">Android ListView State List not showing default item background</a> and <a href="https://stackoverflow.com/questions/2562051/listview-item-background-via-custom-selector">ListView item background via custom selector</a> </p> <p>The proper nine-patch background shows perfectly when I select the list item, but I can not get the default nine-patch background to show initially. It seems to me that I need to set the default item background somehow, but I can't figure out how to do so.</p> <p>List View:</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="fill_parent" android:orientation="vertical"&gt; &lt;TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/shopListHeader" /&gt; &lt;ListView android:id="@+id/shopList" android:layout_width="fill_parent" android:layout_height="wrap_content" android:dividerHeight="0px" android:divider="#FFFFFFFF" android:listSelector="@drawable/shop_list_selector" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>Selector:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;selector xmlns:android="http://schemas.android.com/apk/res/android" android:visible="true"&gt; &lt;!-- the list items are enabled and being pressed --&gt; &lt;item android:state_pressed="true" android:drawable="@drawable/shop_list_item_pressed" /&gt; &lt;item android:state_selected="true" android:textColor="#FFFFFFFF" /&gt; &lt;/selector&gt; </code></pre> <p>Background:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;selector xmlns:android="http://schemas.android.com/apk/res/android" android:visible="true"&gt; &lt;item android:state_selected="true" android:drawable="@android:color/transparent" /&gt; &lt;item android:drawable="@drawable/shop_list_item" /&gt; &lt;/selector&gt; </code></pre> <p>As you can see, I have dumbed down the examples from the references.</p> <p>You may also notice that the Background selector isn't being referenced anywhere. I started tossing it in random places (if the app compiled the addition either had no effect or cause a forced close)</p> <p>I have also made an attempt to stop the color of the text from changing to black and grey when an item is selected but not pressed (can be done by scrolling through the list). Since my background will be black in the center, the text becomes partially invisible when selected. That addition (the last item node in the Selector) does nothing, as far as I can tell.</p> <p>Does anyone have any thoughts on getting this ridiculously time consuming functionality working?</p>
    singulars
    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