This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
AnimateDismissAdapter
nhaarman edited this page Apr 9, 2013
·
1 revision
With the AnimateDismissAdapter
you can select list item positions which you want to remove. The adapter takes care of animating the items out of view. After the animation is done, you need to remove the items from your BaseAdapter
.
- Implement your own
BaseAdapter
, or use an existing one. - Implement a
OnDismissCallback
for yourAnimateDismissAdapter
. - Create a new
AnimateDismissAdapter
, providing yourBaseAdapter
andOnDismissCallback
. - Set your
ListView
to yourAnimateDismissAdapter
. - Set your
AnimateDismissAdapter
to yourListView
. - Call
animateDismiss(Collection<Integer>)
on yourAnimateDismissAdapter
to animate dismissal.
MyListAdapter mAdapter = new MyListAdapter(this, getItems());
OnDismissCallback myOnDismissCallback = new OnDismissCallback() {
@Override
public void onDismiss(ListView listView, int[] reverseSortedPositions){
for (int position: reverseSortedPositions) {
mAdapter.remove(position);
}
}
};
mAnimateDismissAdapter = new AnimateDismissAdapter(mAdapter, myOnDismissCallback);
mAnimateDismissAdapter.setListView(getListView());
getListView().setAdapter(mAnimateDismissAdapter);
public void dismissItems(Collection<Integer> positionsToDismiss){
mAnimateDismissAdapter.animateDismiss(positionsToDismiss);
}