-2

how can i make a RecyclerView of Recycler Views with a superior title in such a way that, when i scroll the screen down, the superior title of this category gets selected.At the same time,i have the possibility of clicking at some title and go to its position of list

First image showing first collection of items

Second image showing that another title was selected

1 Answers1

0

A RecyclerView of a RecyclerView is probably not what you require, instead, what you need is probably a TabLayout where the tabs contain RecyclerView. Here's a nice codelabs example to get you started. You can also create a new Tabbed Activity directly using Android Studio, that'll fill in a lot of the boilerplate code.

Now, if you're absolutely sure that you actually need a RecyclerView containing RecyclerView (I suppose, if you have a list of tabs whose actual values you don't know or which might change and they have properties that allow you to design them as RecyclerView of Tabs), then check out RecyclerTabLayout.

Chrisvin Jem
  • 3,940
  • 1
  • 8
  • 24
  • You can use the tab layout for the horizontal items. But if you want a list with items and category titles in the same list you can use an RecyclerView Adapter with multiple view holders, each one extending a base view holder. So you add in the list the titles as well and you will use the view holder for that type of item. – Tudor Lozba Jun 11 '19 at 13:54
  • Yes, I get that there are use-cases/scenarios where you might actually want to do that, to hopefully make your work simpler. But mostly, you know exactly what tabs are required. And [dynamically adding/removing tabs](https://stackoverflow.com/questions/34306476/dynamically-add-and-remove-tabs-in-tablayoutmaterial-design-android) using `TabLayout` is really simple anyway. – Chrisvin Jem Jun 11 '19 at 14:01
  • The only legit reason (IMO) to use a `RecyclerView` in place of a `TabLayout` is when you have infinite tabs or an extremely large number of tabs. – Chrisvin Jem Jun 11 '19 at 14:04