1

I've HashMap key and JSONArray in Adapter. How to set header as key and array objects as sub items in RecyclerView?

Follwing is the HashMap format for first and second positions getting at adapter class. how to set it in Adapter?

  0 [{"Imgo":"003f2e1f.jpg"},{"Imgo":"063f2e1f.jpg"}] 
   1 [{"Imgo":"003f2e1f.jpg"}]

I'm able to set the header properly. Dont know how to insert the subitems in each header.

Igor Fridman
  • 1,267
  • 1
  • 16
  • 30
SARATH V
  • 500
  • 1
  • 7
  • 33
  • you should use custom adapter for your `RecyclerView` – Hamid Reza Oct 09 '17 at 07:03
  • 1
    In my custom adapter i'm able to set header. How to attach sub items to it? – SARATH V Oct 09 '17 at 07:05
  • You should use a custom adapter that supports two different types. see [ghostAdapter](https://github.com/sajadshokri/GhostAdapter) lib to support any type of items in recyclerview – FarshidABZ Oct 09 '17 at 07:05
  • Use adapter layout with TextViewto set the header and linear layout below that and keep adding imageView programmatically. – Ankit Aman Oct 09 '17 at 07:07

1 Answers1

1

By creating custom adapter view and passing header array and and subitems array seperately in adapter parameters. I ended up with this logic and it works fine. Created seperate header view_holder and subitems viewholder with seperate xml views. The logic will be helpful for others. If any doubts comment here.

SARATH V
  • 500
  • 1
  • 7
  • 33