This app is a demo for the "Work with the OS, not against it" section of the "Building Good Android Apps" talk at BJUG#9.
The purpose of this app is to demonstrate in a simple way how you can use features that the Android OS provides you with in order to create a better user experience. It does this by showing a simple ListView
, allowing you to switch between four ListAdapter
s, each one having 10,000 items:
BadAdapter
is what would be your first attempt at writing a list adpater. It's bad because it creates aView
object (by inflating a layout file) for every list item, not taking advantage of the providedconvertView
.GoodAdapter
uses theconvertView
object, thus greatly reducing the number of objects created by the adapter. This sensibly improves the performance of the app.AwesomeAdapter
implements a trick using thesetTag()
andgetTag()
methods present on theView
object so that it can greatly reduce the number of calls tofindViewById()
, which is pretty expensive.TwoToneAdapter
shows that you don't need to throw these optimizations away when you're doing something more complicated, like having multiple view types in your adapter. All you need to do is implement a couple extra methods so that Android knows what your intentions are.
If you're feeling adventurous, playing with the code is pretty straightforward. Install the Android SDK (if you haven't done so already) and it should be a simple matter of File > Import > General > Existing Projects into Workspace
.