Android ListView with alternate color and on focus color

Posted by Yogesh on Stack Overflow See other posts from Stack Overflow or by Yogesh
Published on 2010-06-17T11:39:30Z Indexed on 2010/06/17 11:43 UTC
Read the original article Hit count: 1132

Filed under:
|
|

I need to set alternate color in list view rows but when i do that it removes/ disables the on focus default yellow background

I tried with backgroundColor rowView.setBackgroundColor(SOME COLOR);

also with backgrounddrwable. rowView.setBackgroundColor(R.drawable.view_odd_row_bg);

<!-- Even though these two point to the same resource, have two states so the drawable will invalidate itself when coming out of pressed state. -->
<item android:state_focused="true" android:state_enabled="false" android:state_pressed="true" android:drawable="@color/highlight" />
<item android:state_focused="true" android:state_enabled="false" android:drawable="@color/highlight" />

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

<item android:state_focused="true" android:drawable="@color/highlight" />

but it wont work.

is there any way we can set background color and on focus color simultaneously which will work.

© Stack Overflow or respective owner

Related posts about android

Related posts about color