Reputation: 11
Hi everyone.
I've come up with an idea for an Android App, and I was thinking how to turn my thoughts into something working. I know how to program for Android even though I'm not that advanced as you might see, so I wanted some tips from you guys who I'm sure will be able to help.
I was thinking about an App to organize stuff, see your objects on a list
and be able to add, move or remove them from the list
.
I first thought I needed a RecyclerView
to display each item. Then I thought every item itself might be a box, and so be containing other items inside: this brought me to think of a sort of "nested" system of RecyclerView
s. Before going too deep into this system I had to clarify each item should have been a Class
, each of which should have had a RecyclerView
assigned.
I was wondering how I could make this "nested" system of RecyclerView
s. I thought about making a RecyclerView
an object
, because I need each RecyclerView
to display, function and be always the same in any screen of any item. But I don't know what the best way is.
Should I make it an object
? How do I create a new RecyclerView
through a button so the user can first tap an item and then, eventually, tap a button (inside the item details view for instance) to make it a box item and so create and open a RecyclerView
when tapped?
It may seem like multiple questions but it actually is only one: how to add and display a RecycerView
when I tap a button inside a details screen of an item, of course automatically (have a reference to that RecyclerView
).
Upvotes: 1
Views: 71
Reputation: 521
You have to create the RecyclerView
that holds your items list, let's call it rv_list
, this RecyclerView
has an adapter that takes each item and adapts it to an xml layout row_item.xml
that you should define. Now to make an item itself display its own recyclerview you should put a recyclerview inside row_item.xml
and populate it when adapting that item to rv_list
inside the method onBindViewHolder
.
Upvotes: 0