Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to work with Selector Listview in Android?
    primarykey
    data
    text
    <p>I have file <strong>lst_custom_view.xml</strong></p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/RelativeLayout1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="top|left" android:background="@drawable/list_choose" android:orientation="horizontal"&gt; &lt;TextView android:id="@+id/textView1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_centerVertical="true" android:layout_gravity="center" android:layout_marginLeft="20dp" android:ellipsize="marquee" android:marqueeRepeatLimit="marquee_forever" android:scrollHorizontally="true" android:singleLine="true" android:textColor="#ff000000" android:textSize="22dp" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p>And Listview in <strong>Main.xml</strong></p> <pre><code>&lt;ListView android:id="@+id/lstView" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginLeft="8dp" android:layout_marginRight="8dp" android:layout_weight="1" android:background="@android:color/transparent" android:cacheColorHint="@android:color/transparent" android:divider="@drawable/menu_phancach" android:dividerHeight="2dp" android:visibility="visible"&gt; &lt;/ListView&gt; </code></pre> <p>I use Selector with Background of Relativelayout with name <strong>list_choose.xml</strong></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="false" android:state_pressed="false" android:drawable="@drawable/menu_content" /&gt; &lt;item android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/menu_content_hover" /&gt; &lt;item android:state_pressed="true" android:drawable="@drawable/menu_content_hover" /&gt; &lt;/selector&gt; </code></pre> <p>it's show me the background of RelativeLayout menu_content_hover when i Press on items listview, but not selected with background menu_content_hover. I want it change background menu_content_hover when user press on items and <strong>selected</strong> ,change backround menu_content when user scroll list(unselected) or choose another items.I used simpleCursorAdapter. Any Help? Thanks for all your help.</p>
    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.
    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