简体   繁体   中英

How add animation for SwipeToDismiss (nhaarman | ListViewAnimations)

I use lib ListViewAnimations by nhaarman.

Сreated ListView and enableSwipeToDismiss:

listView = new MainCurrencyListView(getContext());


adapter = new ItemListAdapter(getContext(), items);

SimpleSwipeUndoAdapter simpleSwipeUndoAdapter = new SimpleSwipeUndoAdapter(adapter, getContext(), new SwipeOnDismissCallback(adapter));
AlphaInAnimationAdapter animAdapter = new AlphaInAnimationAdapter(simpleSwipeUndoAdapter);
animAdapter.setAbsListView(listView);
assert animAdapter.getViewAnimator() != null;
animAdapter.getViewAnimator().setInitialDelayMillis(INITIAL_DELAY_MILLIS);
listView.setAdapter(animAdapter);

//DragAndDrop
listView.enableDragAndDrop();
listView.setOnItemMovedListener(new ListItemMovedListener(adapter));
listView.setOnItemLongClickListener(new ListItemLongClickListener(listView));

/* Enable swipe to dismiss */
listView.enableSimpleSwipeUndo();

This list with drag and drop, and removing elements from the cancellation.

I would like to make a list with drag and drop and easy removal without canceling.

The application example, there is called ' Swipe-To-Dismiss ', but in the code ' example ' on github I did not see this implementation.

Please help, how it can be implemented?

Thank you!

Why don't you do it like in this article. You don't need any special libraries. I'm sure it is good article because I did it few days ago using this tutorial.

The solution found and we can not say that it is intuitive:

/* Enable swipe to dismiss */
//listView.enableSimpleSwipeUndo();
listView.enableSwipeToDismiss(new SwipeOnDismissCallback(adapter));

That is, you need to create first SimpleSwipeUndoAdapter . (That was the animation after the removal of the item)

And then instead of enableSimpleSwipeUndo(); do enableSwipeToDismiss(new SwipeOnDismissCallback(adapter));

Thanks to all!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM