1

I have drawn the headers for items in the Recyclerview selectively, I have inherited the Recyclerview.ItemDecoration class and override onDrawOver method. That is how I have drawn the header. But I don't know how to draw footer for each item?

I have used the same approach as here Header Decore Library

Pruthviraj
  • 560
  • 6
  • 23
  • No. But you can do it by keeping one view at bottom, which visibility will be visible when you wnat – Pankaj Kumar Jan 23 '17 at 10:55
  • Down vote doesn't help anyone. Post a link or answer if you know anything. I have tried this approach. This is not an elegant solution. I am not dealing with small about of data. This approach is little messy and makes a big impact on performance as data increases. – Pruthviraj Jan 23 '17 at 10:59
  • Have you tried using different view type in your adapter?One for normal items and the other for footer. http://stackoverflow.com/questions/26245139/how-to-create-recyclerview-with-multiple-view-type – Anindita Pani Jan 23 '17 at 11:38
  • @Pruthviraj Just for clarification, I did not downvote. So be cool. – Pankaj Kumar Jan 23 '17 at 11:40
  • @Anindita Pani - Yes, I have tried that approach. This approach works fine if there is only one footer for entire recyclerview, My case is different, there could be multiple footers depends on items. Item content updates very often so, I am always be in need of calling method notifyItemChanged(), This method takes index, If I use the above approach I will not be able to give proper index. – Pruthviraj Jan 23 '17 at 11:59
  • you can draw multiple footer by returning footer_type in getItemViewType(int position) by applying check on position – Omer Jan 23 '17 at 12:51
  • @Override public int getItemViewType(int position) { if (// condition for footer) { return TYPE_FOOTER; } else { return TYPE_NORMAL; } } – Omer Jan 23 '17 at 12:53
  • What you are saying is correct I have used getItemViewType in many scenarios. The problem is if I want to update any specific item in the list it will be difficult. On which index I should call notifiItemChanged() method. actual item position in the adapter is different than item's position in the list which is bound to Recyclerview. – Pruthviraj Jan 24 '17 at 04:56

0 Answers0