Search code examples
androidlistviewtabsandroid-browser

How to implement Android 4.0 like swipe to dismiss functionality in ListView?


I'm working on an app in which I would like to implement swipe-to-dismiss functionality in the ListView - similar to what we see in Android 4.0's notification bar, recent apps list or browser tabs. I want to run the app on the devices running Android 2.2+. See the following image. I also want to change the transparency of the item being swiped-away - just like in ICS.

Android 4.0 Web Browser - Swiping away the open tabs

I checked the source of the ICS web browser on http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android-apps/4.0.1_r1/com/android/browser/TabScrollView.java?av=f but couldn't figure out which class is particularly responsible for implementing this functionality.

Can anyone point me in the right direction here? Can we do this using Android Compatibility Library? Please let me know. Many thanks.


Solution

  • I know this is quite an old question, but for anyone still searching for this, you can have a look at Roman Nurik's library here: https://github.com/romannurik/Android-SwipeToDismiss

    This shows how to create the required behavior for list-view as well as for normal views.