Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I style selected item in Android ListView?
    primarykey
    data
    text
    <p>I am an Android newbie trying to learn the UI side of things and it's doing my head in. Here's what I have right now:</p> <p>breeds_listing.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="wrap_content" android:layout_height="wrap_content"&gt; &lt;ListView android:id="@+id/breedsListView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:dividerHeight="0px" android:divider="#00000000"&gt;&lt;/ListView&gt; &lt;/LinearLayout&gt; </code></pre> <p>breeds_listing_item.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="wrap_content" android:layout_height="wrap_content" android:background="@drawable/list_item_background" android:orientation="horizontal" &gt; &lt;TextView android:id="@+id/allbreeds_single_item" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center_horizontal"&gt;&lt;/TextView&gt; &lt;/LinearLayout&gt; </code></pre> <p>list_item_background.xml</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;shape xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;solid android:color="#043402" /&gt; &lt;stroke android:width="3dp" color="#ffff8080" /&gt; &lt;corners android:radius="8dp" /&gt; &lt;padding android:left="10dp" android:top="10dp" android:right="10dp" android:bottom="10dp" /&gt; &lt;/shape&gt; </code></pre> <p>What I am struggling to figure out is how do I style the selected item? At the moment the selected item has a ghastly orange background which, under the rounded green rectangle, gives an orange outline effect. I'm sure I have not done things in line with best practices so any suggestions or improvements would be greatly appreciated.</p> <p>Many thanks, D.</p>
    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.
 

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