I am working on an Android application where I need to create a tree view structure using RecyclerView
. Currently, I have a RecyclerView
item that contains another RecyclerView
, and based on user interaction, the nested RecyclerView
will be visible or hidden. I need to repeat the same behavior for individual sub-items if they contain any children.
However, after making an API call, I don’t know how many children each individual sub-list item can contain. I need to represent these children under their respective parent items, similar to the example image below.
Android TreeView
If we know the number of children, we can manually set that many child adapters. But in this case, I don’t know the number of children available for each sub-diagnosis. Is there any way to use a single item layout and dynamically set the children based on their availability?