0

I have a recyclerview displaying my categories as a list and a ClickListener for for each item. My plan is to show the user a list of items corresponding to the choosen category. Is there an other way than to create an activity+RecyclerView-adapter for each categorie?

Edit:

Categories are in fact Categories, so "herb", "side dishes", etc.. Currently its a data class consisting of "name" and "image"

I have the Activity "Ingredients" and the correspoding Adapter "IngAdapter". The XML for this activity consists of the Recyclerview showing the categories.

The Items for every Categorie will be stored in a room, that has not been created yet.

  • you should add some code to let us see what category means. Assuming category is a data class, normally you make 1 activity/fragment, 1 recyclerview inside this view and 1 adapter. Now if you want to show a list of items from that category (master-detail), you'll probably need another view, recyclerview and adapter but you can re use it between the items from your different categories – danielctf Feb 16 '20 at 16:58
  • I made an edit regarding more information. If I understand correctly you mean I can create a new Activity/Adapter/Recylcerview for the items and reuse it. Then I would add the start of the new Activity (Ingredients) in the ClickListener of the Master-Activity. But how do I change the Items corresponding to the clicked category? – V.Scholz89 Feb 16 '20 at 19:41
  • That's correct. You need to pass to the ingredients activity the list of items you want to display, which will vary according to the category you selected. This [link](https://stackoverflow.com/questions/2091465/how-do-i-pass-data-between-activities-in-android-application) shows you how to pass data from one activity to another. You should pass the whole list to the ingredients activity – danielctf Feb 16 '20 at 20:26

0 Answers0