Android毕设项目功能:商城列表与购物车展示(三)

本篇博客将在前两篇基础上,完成第三个页面购物车页面的基本逻辑代码以及最后支付界面的布局绘制,实现效果图如下:

在商品列表界面的分析中,可知通过购物车的图标点击跳转到购物车界面,然后获取统一数据的buyList集合作为ListView列表的数据源展示,购物车界面布局与商品列表界面布局相似,上中下结构,下面为一个按钮和总计金额TextView表示,金额会随着购物车的内容变化发生改变。

购物车布局activity_shop.xml代码如下:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".hw.ShopActivity">
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#FF0000"
        android:id="@+id/shop_top">
        <TextView
            android:text="购物车"
            android:textSize="22sp"
            android:textColor="#FFFFFF"
            android:padding="15dp"
            android:textStyle="bold"
            android:layout_centerInParent="true"
            android:layout_width="wrap_content"
            android:id="@+id/shop_daily_title_tv"
            android:layout_height="wrap_content" />
        <ImageView
            android:id="@+id/shop_daily_back"
            android:layout_width="wrap_content"
            android:layout_height="30dp"
            android:src="@mipmap/icon_back"
            android:layout_centerVertical="true"
            android:layout_marginLeft="20dp"/>
    </RelativeLayout>
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:id="@+id/shop_bottom">
        <ImageView
            android:layout_width="match_parent"
            android:layout_height="2dp"
            android:background="#000000"/>
        <Button
            android:id="@+id/shop_calculate_btn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="结算"
            android:textColor="#FFFFFF"
            android:layout_margin="10dp"
            android:background="@drawable/buy_button"
            android:layout_alignParentRight="true"/>
        <TextView
            android:id="@+id/shop_cal_tv"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="¥14.50"
            android:textColor="#FF0000"
            android:textSize="22sp"
            android:layout_centerVertical="true"
            android:layout_toLeftOf="@+id/shop_calculate_btn"/>
        <TextView
            android:id="@+id/shop_cal_tv2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="总计:"
            android:textSize="22sp"
            android:layout_centerVertical="true"
            android:layout_toLeftOf="@+id/shop_cal_tv"/>

    </RelativeLayout>
    <ListView
        android:id="@+id/shop_daily_lv"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:dividerHeight="1dp"
        android:layout_below="@id/shop_top"
        android:layout_above="@id/shop_bottom"
        android:divider="#DCDCDC"></ListView>

</RelativeLayout>

ListView列表的每一个item的布局与商品列表界面相似,只不过将购买按钮,编程购物车删除按钮,故布局改变不大,其item布局item_shop.xml代码如下:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="20dp"
    android:descendantFocusability="blocksDes
  • 8
    点赞
  • 55
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值