Friday, July 5, 2013

[android help] ListView Odd Even row xml


ListView Odd Even row xml



This is my listview



android:id="@+id/lvRMultiple"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="52"
android:divider="@color/white"
android:scrollingCache="false" >




I set row background in listview as even and odd as follows :



/*
* CHANGE ROW COLOR 0 WHITE 1 GRAY
*/

if ( position % 2 == 0) //0 even 1 odd..
vi.setBackgroundResource(R.drawable.listview_selector_odd);

else
vi.setBackgroundResource(R.drawable.listview_selector_even);


Now when i select an even or odd row i want the background resource to change.


So in listview_selector_odd.xml













and listview_selector_even.xml












when i run my listview on device and select an even or odd rows nothing happens. does someone know why and what is the correct way to do it based on my answer.



Read more

stackoverflow.comm



No comments:

Post a Comment

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...