0

I have an App that displays lists of data (Random selections from XML files, meant as Inspiration for Authors and Gamers)

When a category is selected, a "Datablock" is Instantiated, holding 50 randomly-created HashMaps, each describing an Entry in that Category. Each HashMap has Key/Value pairs relating to the Category chosen. e.g. "Names" has keys: Forename and Surname. "Treasures" has keys: Style, Item and Value, "Shop" has keys: Name, Descriptor, Type and Quality. For each Key, a random Value is selected from the appropriate XML String_Array.

I am planning to display these in a RecyclerView, using an Adapter. Is it possible to account for the varying amount and type of data in one Adapter, or should I conditionally call a different Adapter for each Category?

Black Spike
  • 142
  • 1
  • 9

1 Answers1

1

You can implement getItemViewType() in your RecyclerView.Adapter and return a different ViewHolder based on the category of the item.

See also: How to create RecyclerView with multiple view type?

Omar Silva
  • 301
  • 1
  • 8