0

I have used SwipeListView to display some contents. i want the color of my Listview to turn to black when it is touched,swiped and till some other row is selected. How can i do that? I have tried the following but it did not help.

 main.xml


 <com.fortysevendeg.swipelistview.SwipeListView
        android:id="@+id/example_swipe_lv_list"

        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        swipe:swipeFrontView="@+id/front"
        swipe:swipeBackView="@+id/back"
       android:background="?android:attr/activatedBackgroundIndicator"
        android:listSelector="@drawable/list_selector"
       android:choiceMode="singleChoice"
        swipe:swipeDrawableChecked="@drawable/choice_selected"
        swipe:swipeDrawableUnchecked="@drawable/choice_unselected"
        swipe:swipeCloseAllItemsWhenMoveList="true"

        swipe:swipeMode="both"
        />

@drawable/list_selector

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

<item android:drawable="@drawable/list_item_bg_normal" android:state_activated="false"/>
<item android:drawable="@drawable/list_item_bg_pressed" android:state_pressed="true"/>
<item android:drawable="@drawable/list_item_bg_pressed" android:state_activated="true"/>
<item android:drawable="@drawable/list_item_bg_normal" android:state_activated="true" ></item>

</selector>
anu_r
  • 1,502
  • 7
  • 27
  • 59

1 Answers1

0

On Scrolling Listview items(Views) are reused. To keep the existing state of the View you have to use a ViewHolder concept.

Check out the links below:

http://developer.android.com/training/improving-layouts/smooth-scrolling.html

findViewById vs View Holder Pattern in ListView adapter

Store the selected item in an Array. Keep checking if the item exists and change the background color in getView()

Community
  • 1
  • 1
mipreamble
  • 1,405
  • 12
  • 17