购物车

1.先写布局

        android:id="@+id/elv"
        android:layout_above="@+id/lin_end"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">

            android:id="@+id/lin_end"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_alignParentBottom="true"
        android:orientation="horizontal"
        android:gravity="center_vertical"
        >
                    android:id="@+id/all"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
                    android:id="@+id/all_count"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="合计:0"
            android:gravity="center"

            />
                    android:id="@+id/all_money"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="计算:0"
            android:gravity="center"

            />
   


2.导library

3.创建jsonbean类

4. 购物车

for (int i=0;i                 flist.add(new GroupBean(data.get(i).getTitle(),false));
                List slist=new ArrayList<>();
                for (int j=0;j                     slist.add(new ChildBean(data.get(j).getTitle(),data.get(j).getPrice()+"",data.get(j).getImages(),false,1));
                }
                clist.add(slist);
            }
            CartUtils.setCartData(MainActivity.this,flist,clist,elv,all,all_count,all_money);

你可能感兴趣的:(购物车)