18

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?

Ashok Varma
  • 3,489
  • 3
  • 28
  • 43
Lord_Gama
  • 287
  • 2
  • 4
  • 12

2 Answers2

8

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.

Community
  • 1
  • 1
G. Kalender
  • 491
  • 4
  • 13
  • thank you, I was stuck thinking about using itemdecoration. but use two View Types was the best answer. – Lord_Gama May 27 '16 at 18:44
1

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

Community
  • 1
  • 1
Ashok Varma
  • 3,489
  • 3
  • 28
  • 43