SimpleCursorAdapter with Sections in Android
Asked Answered
S

2

13

Im at a bit of loss on this one on how to produce sections in a ListView when you use both Cursors and a Custom SimpleCursorAdapter.

Many of the docs out there reference using getView() etc, or creating several Adapters and adding section headers.

But these all appear to be based on BaseAdapters, ListAdapters, and ArrayAdapters etc.

Has anybody dealt with anything similar previously?

If not, any tips on how to make this work?

Thanks Simon

Surfacetoair answered 9/1, 2011 at 17:53 Comment(0)
C
9

If you're using a CursorAdapter, you can use my SectionCursorAdapter.

Contemplative answered 1/9, 2011 at 10:24 Comment(3)
Cheers, this worked great with SimpleCursorAdapters to have alphabetized sections in my ListView. This was a lot more work than I thought, I think SimpleCursorAdapter spoiled me in it's simplicity!Gene
It's not efficient for the database SimpleCursorAdapter with long list of items since you have to iterate over all the items to calculate the header. If the cursor is returned with a GROUP BY query then it's a lot better to compare the header (the grouped value) of the current item agains that of the previous & next items to determine if we have a new section or not.Adapter
You may want to use AlphabetIndexer for calculating sections.Hunnish
A
2

Another great one which is in active development is SectionCursorAdapter and it supports gradle. The creator of the it has also promised that it will be updated to support RecyclerView when it is officially released. You can also check out the blog post about it at ToastDroid

Ascendancy answered 2/10, 2014 at 13:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.