仿电商App:笔记(八):主界面-首页UI与数据解析器开发(RecyclerView)

目录

1、创建首页UI

2、首页下拉刷新实现

2.1 刷新助手 

 2.2 初始化刷新功能

2.3 效果图:

3、首页数据结构分析

3.1 获取本地json数据

3.2 在刷新功能中进行数据访问

3.3 初始化第一页数据

4、多布局高可用性RecyclerView封装和数据解析器

4.1 封装数据实体类--保存数据(软引用)

4.2 数据转换根类

4.3 首页的数据转化类

5、RecyclerView封装和数据适配器打造(适配各种数据,将数据与对应的View绑定)

5.1 ViewHolder封装

5.2 数据适配类--Adapter(简单工厂模式)

5.3 设置Banner的类型

6、主页分页逻辑

6.1 分页相关数据类

6.2 第一页数据配置

6.3 加载第一页数据

6.4 数据之间分割线设置--装饰设计模式

6.5 结果图 

7、沉浸式状态栏设置

7.1 隐藏状态栏

7.2 标题栏的颜色变化设置

7.3 渐变行为的应用

7.4 结果图

8、添加首页动作

8.1 为每个item添加点击事件

8.2 首页中初始化点击事件

8.3 点击item跳转的界面

8.4 效果图

1、创建首页UI

布局文件

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
//有商品展示,因此界面会出出现上拉刷新,下拉加载更多
    <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
        android:id="@+id/srl_index"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/rv_index"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
//写在下面,防止嵌套滑动,会被新的元素遮住,两边是字体图标:扫描、信息,中间是搜索框
    <androidx.appcompat.widget.Toolbar
        android:id="@+id/tb_index"
        android:layout_width="match_parent"
        android:layout_height="80dp"
        android:background="@android:color/transparent"
        app:layout_behavior="com.example.latte.ec.main.index.TranslucentBehavior">

        <androidx.appcom
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值