E-commerce projects often have shopping cart this function, do a lot of projects, have a different interface, choose one to talk about.
Mainly includes the store classification, side-by-side removal, product selection, increase and decrease, price calculation and other functions.
Look:
Important Code:
Private voidShowexpanddata () {Cartexpandadapter=NewCartexpandadapter ( This, Cartexpandablelistview,cartinfo.getdata ()); Cartexpandablelistview.setadapter (Cartexpandadapter); intIntgroupcount =Cartexpandablelistview.getcount (); for(inti=0; i<intgroupcount; i++) {cartexpandablelistview.expandgroup (i); } /*** Select All*/Cartexpandadapter.setonitemclicklistener (NewOnviewitemclicklistener () {@Override Public voidOnitemclick (BooleanIsflang, view view,intposition) {Cartinfo.getdata (). get (position). Setischeck (Isflang); intLength=cartinfo.getdata (). get (position). GetItems (). Size (); for(inti = 0; i < length; i++) {cartinfo.getdata (). get (position). GetItems (). get (i). Setischeck (Isflang); } cartexpandadapter.notifydatasetchanged (); Showcommoditycalculation (); } }); /*** Radio*/Cartexpandadapter.setonclicklistentermodel (NewOnclicklistentermodel () {@Override Public voidOnitemclick (BooleanIsflang, view view,intOneposition,intposition) {Cartinfo.getdata (). Get (Oneposition). GetItems (). get (position). Setischeck (Isflang); intLength=cartinfo.getdata (). Get (Oneposition). GetItems (). Size (); for(inti = 0; i < length; i++) { if(!cartinfo.getdata (). Get (Oneposition). GetItems (). get (i). Ischeck ()) { if(!Isflang) {Cartinfo.getdata (). Get (Oneposition). Setischeck (Isflang); } cartexpandadapter.notifydatasetchanged (); Showcommoditycalculation (); return; }Else { if(i== (length-1) {cartinfo.getdata (). Get (Oneposition). Setischeck (Isflang); Cartexpandadapter.notifydatasetchanged (); }}} showcommoditycalculation (); } }); Cartexpandadapter.setonclickdeletelistenter (NewOnclickdeletelistenter () {@Override Public voidOnitemclick (View view,intOneposition,intposition) {Toast.maketext (mainactivity). This, delete action, Toast.length_long). Show (); } }); /*** * Quantity increase and decrease*/Cartexpandadapter.setonclickaddcloselistenter (NewOnclickaddcloselistenter () {@Override Public voidOnitemclick (View view,intIndexintOneposition,intPositionintnum) { if(index==1){ if(num>1) {cartinfo.getdata (). Get (Oneposition). GetItems (). get (position). setnum (Num-1)); Cartexpandadapter.notifydatasetchanged (); } }Else{cartinfo.getdata (). Get (Oneposition). GetItems (). get (position). setnum (Num+ 1)); Cartexpandadapter.notifydatasetchanged (); } showcommoditycalculation (); } }); }
This is the shopping cart used in my project, the basic functions have been.
The need of the boys, you can refer to.
Code Portal
Android-----Shopping Cart (includes slide-slip removal, product screening, product increase and decrease, price calculation, store classification, etc.)