Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>What about adding this line in your item view?</p> <pre><code>android:background="?android:attr/activatedBackgroundIndicator" </code></pre> <p>For instance:</p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="?android:attr/activatedBackgroundIndicator" android:orientation="vertical" &gt; &lt;TextView android:id="@+id/textViewListRowOption" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_vertical" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>Then the selector looks something like this:</p> <pre><code>&lt;selector xmlns:android="http://schemas.android.com/apk/res/android" android:exitFadeDuration="@android:integer/config_mediumAnimTime"&gt; &lt;item android:drawable="@drawable/list_pressed" android:state_pressed="true"/&gt; &lt;item android:drawable="@drawable/list_selected" android:state_activated="true"/&gt; &lt;item android:drawable="@drawable/list_default"/&gt; &lt;/selector&gt; </code></pre> <p>And the list view:</p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" &gt; &lt;ListView android:id="@+id/listViewMainFragment" android:layout_width="match_parent" android:layout_height="wrap_content" android:listSelector="@drawable/list_item_selector" android:choiceMode="singleChoice"&gt; &lt;/ListView&gt; &lt;/LinearLayout&gt; </code></pre>
 

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