I've setup swipe list view with https://github.com/47deg/android-swipelistview. It does provide various event listeners to handle swipe related events.
Everything works perfectly except one thing.
I want to change background color of swiped list item only. It revert back once it gets back.
I can do this with tap event from adapter. I could've used list adapter to do this but since I want to change background on swipe left (listener ) only, I can not use adapter. So doing this from adapter might not work.
Following listeners work for me -
swipeListView.setSwipeListViewListener(new BaseSwipeListViewListener() {
@Override
public void onOpened(int position, boolean toRight) {
View v = swipeListView.getChildAt(position);
swipeListView.getChildAt(position).setBackgroundColor(Color.CYAN);
ci = u_items.get(position); // getter of list item data
Toast.makeText(getApplicationContext(), ci.getTitle().toString(), Toast.LENGTH_SHORT).show();
}
@Override
public void onClosed(int position, boolean fromRight) {
}
@Override
public void onListChanged() {
}
. // other listeners
.
.
.
.
.
This does not throw any error or warning but I can't see background being changed. Toast does show up so swipe left listener is actually working.
Perhaps, I'm doing something wrong while setting background itself. Not sure what. Since, swipelistview is custom view that extends ListView I can't imagine how to do this from that listener only.
Even, I could've used android list selection to set background color in XML file but it works with tap listener only. So this option is also eliminated.Other than this everything else works so perfect.
A push in right direction would be good. If any code is needed further to analyze I can edit question.
you already defined v so you can use it better for you and easier.