Selected List Item Color Moves On Scrolling The Listview In Android
In my Android application I am using listview. The code for list view is as follows
Solution 1:
seems uncleared states in selector causing this . use one like
<?xml version="1.0" encoding="utf-8"?><selectorxmlns:android="http://schemas.android.com/apk/res/android"><!-- Selected --><itemandroid:state_focused="true"android:state_selected="false"android:drawable="@drawable/focused"/><!-- Pressed --><itemandroid:state_selected="true"android:state_focused="false"android:drawable="@drawable/pressed" /><!-- default --><itemandroid:drawable="@drawable/default" /></selector>
Solution 2:
add line in getView() method; convertView.setBackgroundResource(selectedItemInAactivityList.contains.(arrayListSetInAdaptor.get(position) ? r.drawable.selected : R.drawable.transperant));
This one line solved your problem
Solution 3:
Store clicked/selected positions in a set or array in your onItemClick() method. Write code to handle color in getview() method of your adapter using stored positions.
Post a Comment for "Selected List Item Color Moves On Scrolling The Listview In Android"