Home > Software design >  list adapter with sections
list adapter with sections

Time:11-21

I already have a list adapter that works properly. But I want to divide the object in the list into sections according to the date they were created. Something like this:

enter image description here

I found something called "sectioned recycler view" but couldn't find any documentation on that. I read all the related questions, but they all are either outdated or use a third-party library. What's the native way of implementing this feature?

CodePudding user response:

You could create 2 types of view holders:

  1. header which holds the date
  2. data container which holds the other information.

And then create a list of objects which contain something like this: listToBind = (header, data, data, header, data, data)

CodePudding user response:

If you are using Jetpack Compose you can use the stickyHeader() as documented in the documentation

  • Related