Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stick Android ListView "categories" to top

Im working on an application where I load items from a webservice and display them in a list using ListView. I was wondering if I could have certain "titles" between some of them, and when you scroll through them, they stick to the top of the list, until another "title" comes and takes the spot. An example of this is the Android contacts application:

http://img196.imageshack.us/img196/1440/contactss.png

NOTE: Since I can't post images yet, I posted the direct link

The letters G, H and J. How can I achieve this?

like image 870
Hidde Avatar asked Apr 22 '11 18:04

Hidde


2 Answers

The good thing about Android is you can always look at the application source. It uses a PinnedHeaderListView to implement the behavior you are looking for.

like image 53
Rohit Avatar answered Oct 26 '22 04:10

Rohit


Searching on Google I found a nice code of ListView with sticking categories, also includes a working sample project:

http://code.google.com/p/android-amazing-listview/

like image 2
Tony Ceralva Avatar answered Oct 26 '22 04:10

Tony Ceralva