购物车的第二种方法的xml以及依赖和权限

//权限

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

//依赖

implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.squareup.okhttp3:okhttp:3.11.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.11.0'
implementation 'com.github.bumptech.glide:glide:4.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
implementation 'com.android.support:recyclerview-v7:27.1.1'

 

//main的xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <!--标题栏-->
    <RelativeLayout
        android:id="@+id/rl_title"
        android:layout_width="match_parent"
        android:layout_height="48dp">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:text="购物车" />

        <TextView
            android:id="@+id/txt_edit_or_finish"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:padding="5dp"
            android:text="编辑" />

    </RelativeLayout>

    <!--底部结算-->
    <RelativeLayout
        android:id="@+id/rl_bottom"
        android:layout_width="match_parent"
        android:layout_height="48dp"
        android:layout_alignParentBottom="true">

        <CheckBox
            android:id="@+id/cb_total_select"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:text="全选" />

        <TextView
            android:id="@+id/txt_total_price"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:layout_marginLeft="10dp"
            android:layout_toRightOf="@id/cb_total_select"
            android:textColor="#c23636" />

        <Button
            android:id="@+id/btn_calu"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:text="结算" />
    </RelativeLayout>

    <android.support.v7.widget.RecyclerView
        android:id="@+id/rv_shopper"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@id/rl_bottom"
        android:layout_below="@id/rl_title"></android.support.v7.widget.RecyclerView>

</RelativeLayout>

//item_add_decrease

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="70dp"
    android:layout_height="wrap_content">

    <TextView
        android:id="@+id/txt_decrease"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#e78b8b"
        android:padding="5dp"
        android:text=" - " />

    <TextView
        android:id="@+id/txt_add"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:background="#e78b8b"
        android:padding="5dp"
        android:text=" + " />

    <TextView
        android:id="@+id/txt_num"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_toLeftOf="@id/txt_add"
        android:layout_toRightOf="@id/txt_decrease"
        android:gravity="center"
        android:maxLength="3" />
</RelativeLayout>

//item_product.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:paddingBottom="5dp"
    android:paddingLeft="20dp"
    android:paddingRight="5dp"
    android:paddingTop="5dp">

    <CheckBox
        android:id="@+id/cb_product"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@null" />

    <ImageView
        android:id="@+id/img_product"
        android:layout_width="45dp"
        android:layout_height="45dp"
        android:layout_marginLeft="10dp"
        android:layout_toRightOf="@id/cb_product" />

    <com.bwie.cart1023.widget.AddDecreaseView
        android:id="@+id/adv_product"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"></com.bwie.cart1023.widget.AddDecreaseView>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_toLeftOf="@id/adv_product"
        android:layout_toRightOf="@id/img_product"
        android:orientation="vertical">

        <TextView
            android:id="@+id/txt_product_name"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp" />

        <TextView
            android:id="@+id/txt_single_price"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </LinearLayout>

</RelativeLayout>

//item_shopper

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:orientation="horizontal"
        android:padding="5dp">

        <CheckBox
            android:id="@+id/cb_shopper"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@null" />

        <TextView
            android:id="@+id/txt_shopper_name"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </LinearLayout>

    <android.support.v7.widget.RecyclerView
        android:id="@+id/rv_product"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

    </android.support.v7.widget.RecyclerView>

</LinearLayout>

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值