前言
上一篇博客主要介绍了本次网上商城的实现过程中的一些用法,这篇博客主要就是说明每个功能模式的实现方法
Android学习之网上商城(上)
Android学习之网上商城(下)
源码下载:
链接:https://pan.baidu.com/s/1Z17xBHV9iq70LwdgXxwDIQ
提取码:Lin2
本博客内容原创,创作不易,转载请注明
本文链接
个人博客:https://ronglin.fun/?p=120
PDF链接:见博客网站
优快云: https://blog.youkuaiyun.com/RongLin02/article/details/121876819
开发环境:
- Android Studio版本:(Android Studio Arctic Fox 2020.3.1 Patch 3)
- SDK版本:(Android 7.0 API24 Revision 2)
- Gradle版本:(7.0.2)
- Android Gradle Plugin版本:(7.0.3)
文件布局如下:

数据结构
Goods
对于每一个商品类,提供以下的成员变量
private ArrayList<Bitmap> bitmaps;
private String goodsName;
private String describe;
private ArrayList<String> tags;
private int price;
public static ArrayList<Goods> GOODSLIST =new ArrayList<>();
public static Goods DEULT_GOODS = new Goods();
简单介绍一下,price变量是一个以分为单位的数,比如10000就是100.00元,这样就不会涉及到浮点数的精度问题,bitmaps是一个图片的合集,用来保存商品的一些预览图,其他就见名知意了。然后DEULT_GOODS默认商品类就是一个有内存但是没有数据的类
构造方法如下:
public Goods(){
this.bitmaps = new ArrayList<>();
this.goodsName = "";
this.describe = "";
this.tags = new ArrayList<>();
this.price = -1;
}
public Goods(String goodsName, String describe, String[] tags, int price){...}
除了成员变量的getter方法和setter方法还有以下方法:
public boolean equals(Goods goods){
return this.getGoodsName().equals(goods.getGoodsName())
&& this.getTags().equals(goods.getTags())
&& this.getDescribe().equals(goods.getDescribe())
&& this.getPrice() == goods.getPrice();
}
public static String toPriceString(int price){
StringBuffer sb = new StringBuffer(String.value

本文详细讲述了作者如何使用Android开发一个网上商城应用,包括数据结构(如Goods和Person类)、数据库设计(person和shopping表)、注册登录流程、商品展示与搜索、购物车功能及支付流程。通过实例展示了数据库操作、界面设计和关键功能的实现方法。
最低0.47元/天 解锁文章
1834

被折叠的 条评论
为什么被折叠?



