Change color of listview selected item

129 views Asked by At

This is the code that I am using for my ListSelector. Originally all items have transparent background. On press, they become red. When I lift my finger, the background returns to transparent. But, I dont want it to return to transparent. How do I ensure that the color remains red even after I have lifted my finger?

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" tools:ignore="RequiredSize,RequiredSize">

<item android:drawable="@layout/gradient_bg" android:state_pressed="false" android:state_selected="false" tools:ignore="RequiredSize"/>
<item android:drawable="@layout/gradient_bg_hover" android:state_pressed="true" tools:ignore="RequiredSize"/>
<item android:drawable="@layout/gradient_bg_hover" android:state_pressed="false" android:state_selected="true"/>

</selector>
0

There are 0 answers