Android购物车的总结

本文总结了Android购物车的实现,包括购物车布局的设计,使用背景shape,自定义二级列表的展示,数据bean中实现的方法,二级列表适配器的数据加减操作,以及在Activity中的具体应用。
摘要由CSDN通过智能技术生成

购物车布局

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.newshoppcart.view.ShoppCartActivity">

    <RelativeLayout
        android:id="@+id/text_title"
        android:layout_width="match_parent"
        android:layout_height="50dp">

        <ImageView
            android:layout_centerVertical="true"
            android:id="@+id/detail_image_back"
            android:padding="5dp"
            android:src="@drawable/leftjiantou"
            android:layout_width="40dp"
            android:layout_height="40dp" />

        <TextView
            android:layout_centerInParent="true"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:textSize="18sp"
            android:padding="10dp"
            android:text="购物车" />

    </RelativeLayout>

    <com.scwang.smartrefresh.layout.SmartRefreshLayout
        android:layout_below="@+id/text_title"
        android:layout_above="@+id/linear_bottom"
        android:id="@+id/smart_refresh"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scrollbars="none">

                <!--二级列表登录的按钮-->
                <com.example.newshoppcart.view.custom.MyExpanableView
                    android:id="@+id/my_expanable_view"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:visibility="gone">

                </com.example.newshoppcart.view.custom.MyExpanableView>

        </ScrollView>

    </com.scwang.smartrefresh.layout.SmartRefreshLayout>

    <RelativeLayout
        android:layout_above="@+id/linear_bottom"
        android:layout_below="@+id/text_title"
        android:id="@+id/relative_progress"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="gone">

        <ProgressBar
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true" />

    </RelativeLayout>


    <LinearLayout
        android:id="@+id/linear_bottom"
        android:layout_alignParentBottom="true"
        android:gravity="center_vertical"
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="50dp">

        <CheckBox
            android:button="@null"
            android:background="@drawable/check_box_selector"
            android:layout_marginLeft="10dp"
            android:id="@+id/cart_check_all"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <TextView
            android:layout_marginLeft="5dp"
            android:text="全选"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <TextView
            android:textSize="20sp"
            android:layout_marginLeft="10dp"
            android:id="@+id/text_total"
            android:text="合计:¥0.00"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content" />


        <TextView
            android:paddingLeft="15dp"
            android:paddingRight="15dp"
            android:paddingTop="10dp"
            android:paddingBottom="10dp"
            android:id="@+id/text_buy"
            android:gravity="center"
            android:background="#ff0000"
            android:textColor="#ffffff"
            android:text="去结算(0)"
            android:layout_width="wrap_content"
            android:layout_height="match_parent" />

    </LinearLayout>

</RelativeLayout>

全选用到的背景shape

<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:state_checked="true" android:drawable="@drawable/shopping_cart_checked"/>
    <item android:state_checked="false" android:drawable
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值