Jeremy Edwards
Jeremy Edwards

Reputation: 14740

Android ListView Headers

How do you make those standard header labels in the ListView Control?

An example would be in the contacts application you see the first letter of the grouped contacts for each letter in the alphabet.

If possible please provide some code snippets on how to construct the grouped data and the display of the ListView.

Upvotes: 32

Views: 51464

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006604

You can use my MergeAdapter or Jeff Sharkey's SeparatedListAdapter for that.

In the case of MergeAdapter, you would add an ordinary View (e.g., TextView) for a section header, then an Adapter for the contents of that section. Lather, rinse, repeat.

Upvotes: 32

Related Questions