Custom ListViews in Android

Quick post about some code I threw together yesterday for a project. Needed to make some uber custom listviews for a project at work so decided to just create a test package and have at it, there are a ton of resources already online but figured i’d take the best parts of each and make a nice clean project if anyone else wanted to check it out. (ignore package name, not using net.trippedout since i started it at work and been in a habit of naming stuff this way)

Simple answer – extend ArrayAdapter and create a model to hold your data for the list item you’re trying to populate, override getView in your custom ArrayAdapter and create/update the view (referenced by your xml layout id) as needed. Fairly straightforward but could still use some tweaks. If you are going to use this in conjunction with drawables, just pass reference ids to the images you’ll be using and your good to go. My task today is to figure out the best practices of downloading groups of images/data from the network on a phone while still saving battery and caching stuff as I need it. If I come up with anything good I’ll be sure to share it.

Code is here: https://github.com/trippedout/CustomListViews

Comments/Questions hit me up here or @trippedout!

*Edit: adding pic of final product
Screenshot of custom listview

Leave a Reply

Your email address will not be published. Required fields are marked *