Rapid development of Android shopping cart project

Shopping cart project, the business needs to implement a shopping cart project. Simply understand the implementation logic: data calculation is calculated in the adapter. Through the data calculated in the adapter, you can call back to the activity for order operation and other functions. The business logic goes through a process for the data generated by each store, (business requirements: not as a platform similar to Taobao, JD's platform data is distributed by the platform, so we realize the transaction process of one-to-one customer transaction) then look down:

1. Controls used in the interface

2. Data interfaces used in the project

Interface callback of the check box in the interface

Interface for adding and modifying goods

3. Calculate the amount and quantity of goods in the adapter

There are multiple commodities in a single store, so the layout of the store includes the button to select the whole group, and uses the callback checkinterface. Checkgroup (group position) of the interface(( Check@R_156_2419 @) v).isChecked()); To determine whether to select the whole group, facilitate the data in the activity, and refresh the data after selecting the commodity.

Calculate convenience data in activity

Calculate data results in goods:

The above code first determines whether the current group is the last in a store, locally calculates the data of the current group in the last element, selects whether to reset the data display and display according to the data, displays the calculated data, and finally jumps to the interface through interface callback to transfer the data to the activity. This completes the logic of the shopping cart. The above may not conform to your logic, but you can use it with a little modification.

GitHub address: https://github.com/anhuifix/singleShopCar/tree/master

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>