WayWay WayWay - 9 months ago 48
Android Question

Android ListView with section headers in a grouped table format similar to iOS UITableView

I have a ListView but I would like to incorporate section headers into the list view.

However, how would I create these section headers? Through xml?

Additionally, I would also like for them to stick to the top of the ListView until the user scrolls into the next section.

A really good example of such implementation can be found in the default People app which is bundled with Android.

This is what I have for my list view:

<?xml version="1.0" encoding="utf-8"?>
< LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

< ListView
android:layout_gravity="start"/ >

< /LinearLayout>

Answer Source

There is no way to do this in xml, you can use something like: https://github.com/emilsjolander/StickyListHeaders