Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RealmBaseAdapter with section headers

I'm trying to use the realm data store for Android and i'm trying to build an application that shows the user a list of options in a ListView, kind of like the users contact list. The first letter for each section (such as A, B, C, etc.) should be a header. Is there a way to achieve this with RealmBaseAdapter?

Currently I have it working with ArrayAdapter and I simply have an array with values populated but would like to pull data from Realm using its adapter if possible. I know in iOS this is fairly straight forward using the NSFetchedResultsController. How do we break up the RealmResults into sections?

like image 622
KVISH Avatar asked Oct 31 '22 03:10

KVISH


1 Answers

RealmBaseAdapter doesn't work with ExpandableListAdapter (which I am assuming you are using for sections?), so right now your only choice is creating your own implementation. But a RealmResults is also a List so it should work seamlessly with an ArrayAdapter.

You can also see more details here: https://github.com/realm/realm-java/issues/978

like image 179
Christian Melchior Avatar answered Nov 15 '22 14:11

Christian Melchior