Sasikumar
Sasikumar

Reputation: 1043

Android Listview Focus with child view as background

In my app i'm setting background to each child views in listview. So that listview default focus ( orange color ) is not focusing.

Is there any way to set both ( listview focus & child view background ) ?..

Edit: This is my code:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="schemas.android.com/apk/res/android">;
    <item android:state_focused="true" 
    android:state_pressed="false" 
    android:drawable="@drawable/img_focused" /> 

    <item android:state_focused="true" 
    android:state_pressed="true" 
    android:drawable="@drawable/img_selected" /> 

    <item android:state_focused="false" 
    android:state_pressed="true" 
    android:drawable="@drawable/img_selected" />

    <item android:drawable="@drawable/img_default" />
</selector>

Upvotes: 0

Views: 1105

Answers (2)

Vishal
Vishal

Reputation: 21

You can try following states sort order:

<item android:drawable="@drawable/poster_pressed" android:state_pressed="true"/>
<item android:drawable="@drawable/poster_focused" android:state_focused="true"/>

Upvotes: 2

ognian
ognian

Reputation: 11541

It is possible if you define the item background as StateListDrawable. In XML it's done with selector

Upvotes: 0

Related Questions