Himanshu
Himanshu

Reputation: 13

Add an item at a specific location in recycler view without refreshing the recyclerview completely

I need to show a list of data which can be expanded further. Here for showing the list, I've used RecyclerView, but I'm open to use any other widget too. This list should be able to do following tasks:

  1. Add an item at any given specific position and not only at end or start of the list
  2. Pinch in and Pinch out for expanding and collapsing effect
  3. The list will be expanded upto 6 levels so simple expandable listview wont work in this case

Eg.

  1. List of years
  2. Every year contains list of quarters
  3. Every quarter contains list of months
  4. Every month contains list of weeks
  5. Every week contains list of days
  6. Every day contains list of hours

so here I will first show all years, and any year can be further expanded to its quarters followed by months and so on

for doing this, i need to be able to add an item at a particular desired position in the list means if there are 5 years viz. 2011, 2012, 2013, 2014, 2015. I can expand only 2012 and show a list like 2011, quarter 1 of 2012, quarter 2 of 2012, quarter 3 of 2012, quarter 4 of 2012, 2013, 2014, 2015.

Upvotes: 0

Views: 110

Answers (1)

Divers
Divers

Reputation: 9569

You should add your item in data set which your adapter use to show in RecyclerView, after that call

adapter.notifyItemInserted(position)

Doc

Upvotes: 1

Related Questions