怪我咯2017-04-17 15:40:21
Listview nested listview will definitely explode. It is recommended to get out of the pit as soon as possible and use ExpandableRecyclerAdapter or the like
迷茫2017-04-17 15:40:21
I have written a 3-layer ListView, and the interactions and data types of each layer are different.
Tell me a few ways I have thought about it:
ListView nested ListView: Not advisable, each second-level ListView cannot be efficiently reused.
ListView nested LinearLayout: By clicking, control whether the next-level ListView is visible: depending on the scenario, if it is a simple level LinearLayout, it can be considered with only 1~2 layers, but like you Don't use multi-layered ones, because you have to Inflate new layouts many times, and reuse between different secondary ListViews is another problem.
AddView after clicking on ListView: After clicking on an item, add sub-data after the index of the item, handing over the reuse of the interface to the system Listview component, with high reuse. However, it has requirements on your data architecture and needs to be removed manually. It's one that can be considered.
Use ExpandableListView: This should be very consistent with your requirements! Recommended.
If you are not using Listview but RecycleView, you can consider using the ExpandableRecyclerAdapter mentioned by the author above.