The CommonsBlog

TouchListView 0.1 Released

The Android open source project has had this tantalizing TouchInterceptor class, inside the Music app, that is effectively a ListView that supports drag-and-drop. When people ask on StackOverflow or wherever about drag-and-drop lists, we inevitably point them to this code. However, as it stands, that code has a few things that are tied into the Music app, and so it cannot be reused without some work.

Until now.

I have released TouchListView as one of the CommonsWare Android Components. This is 99% Android open source code. The rest is where I replaced some hard-wired values with attributes for use with XML layout files. I also have a sample project demonstrating its use, to allow you to rearrange or remove items from a list of 25 nonsense words.

You can view the source code for it on GitHub. You can also get it in parcel format if you prefer to avoid dealing with compiling it. Since it uses attribute resources, it cannot be packaged as a standalone JAR.

Many thanks to the Android open source project for making this code available. Trying to write one from scratch would have been unpleasant, particularly since I have done next to nothing to date with touch events and therefore would have had no idea how to implement it.

If you have any questions about TouchListView, please join the cw-android Google Group and ask them there!

Need an Android programming guide for your development team? An Enterprise Warescription to The Busy Coder’s Guide to Android Development is available for teams of 10+ members. Contact Mark Murphy for details.