Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grouping recycler-view items by date? [closed]

I need to group my recycler-view data based on a date and show some dividers in between each group as shown below.

--Item #1--

--Item #2--

 -- January 2016(Divider)--

--item #3--

--item #4--

--item #5--

-- December 2015(Divider)--

--item #6--

--item #7--

.... ....

how I can accomplish this?

like image 597
Lord_Gama Avatar asked May 26 '16 22:05

Lord_Gama


2 Answers

Sounds like you just want to have two ViewTypes like explained here

You might also want to take a look at this library and if you want it to be expandable and sexy you could take a look at Advanced RecyclerView library.

like image 132
G. Kalender Avatar answered Oct 07 '22 17:10

G. Kalender


You need to first sort them based on the date.

then use either view_type (Is there an addHeaderView equivalent for RecyclerView?) as @G.K mentioned or use any recycler header library to set them as sticky headers.

try this : https://github.com/ShamylZakariya/StickyHeaders

like image 30
Ashok Varma Avatar answered Oct 07 '22 17:10

Ashok Varma