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.
This example demonstrates How to add header item for Listview in Android. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With