The logic of nested selection of recyclerview or listview in Taobao shopping cart is implemented in Android
The scheme of nested recyclerview using recyclerview.
The first interface of the shopping cart is recyclerview, and each item contains a store. Use recyclerview in item to include stores and multiple items in stores.
Implementation idea:
Use the interface callback to call back the listening event selected by the commodity of the second adapter to the first adapter, and then call back to mainactivity in the first adapter.
Use the interface callback to callback the listening event selected by the commodity of the first adapter to mainactivity.
Handle the event listening of the first adapter and the second adapter in mainactivity.
MainActivity:
First adapter:
Second adapter:
Entity class saves data and selection status:
Layout files: activity_ main.xml
shop_ item.xml:
check_ item:
Simple renderings:
The above is the logic of nested selection of recyclerview or listview in Taobao shopping cart in Android introduced by Xiaobian. I hope it will be helpful to you. If you have any questions, please leave me a message and Xiaobian will reply to you in time. Thank you very much for your support for the programming tips website!