Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Notification-like list element deletion on slide-out in Android

I wonder how can I make a ListView's elements slide out on slide, like the way you can slide a notification from the notifications bar in Android. This is my situation:

I have a list of items, and, when the user wants to remove an item from this list, she simply slides an element towards the edge of the screen. I would like this slide-out to be visible, e.g. to use some kind of animation that slides out that given View holding the item.

Here are some images to illustrate this.

First, this is the normal state of the notification.

Normal state of notification

And then, this is during slide-out

State during slide-out

Thanks.

like image 311
overbet13 Avatar asked Aug 14 '12 12:08

overbet13


2 Answers

The Android class com.android.systemui.statusbar.policy.NotificationRowLayout (Android 4.1.1 versions throughout) appears to be the manager of the notification bar rows, and it uses a helper class com.android.systemui.SwipeHelper which appears to do precisely the sort of thing you want.

So NotificationRowLayout is an example of the use of SwipeHelper which is hopefully the thing you were looking for!

like image 136
not all wrong Avatar answered Oct 22 '22 22:10

not all wrong


Roman Nurik (Android developer advocate) created a quick-and-dirty swipe-to-dismiss implementation. Jake Wharton backported it, using NineOldAndroids, to work on earlier Android versions. You might give one of those a try.

like image 23
CommonsWare Avatar answered Oct 22 '22 22:10

CommonsWare