【0109】【项目实战】-【Android通用框架设计与完整电商APP开发】-【9】【 主界面-商品分类开发(多布局Section RecyclerView)】


1. 分类页面结构解析和开发

【说明】底部的是一个大的容器fragment,左边的是一个fragment,右边是一个fragment;

【说明】分类的界面的内容分为两类,左边的是list,右边是与list对应的详情页面;因此,在文件夹分类的时候也是:content详情页面;list:分类页面;

1.1 布局的创建

 

【源码】layout/delegate_sort.xml

 

 1 <?xml version="1.0" encoding="utf-8"?>
 2 <android.support.v7.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android"
 3     android:layout_width="match_parent"
 4     android:layout_height="match_parent"
 5     android:orientation="vertical">
 6 
 7     <android.support.v7.widget.Toolbar
 8         android:layout_width="match_parent"
 9         android:layout_height="60dp"
10         android:background="@android:color/holo_orange_dark"
11         android:gravity="center">
12 
13         <android.support.v7.widget.AppCompatTextView
14             android:layout_width="match_parent"
15             android:layout_height="match_parent"
16             android:gravity="center"
17             android:paddingTop="6dp"
18             android:text="分类"
19             android:textColor="@android:color/white"
20             android:textSize="20sp" />
21 
22     </android.support.v7.widget.Toolbar>
23 
24     <android.support.v7.widget.LinearLayoutCompat
25         android:layout_width="match_parent"
26         android:layout_height="match_parent"
27         android:background="@color/app_background"
28         android:baselineAligned="true"
29         android:orientation="horizontal">
30 
31         <android.support.v7.widget.ContentFrameLayout
32             android:id="@+id/vertical_list_container"
33             android:layout_width="0dp"
34             android:layout_height="match_parent"
35             android:layout_weight="1" />
36 
37         <android.support.v7.widget.ContentFrameLayout
38             android:id="@+id/sort_content_container"
39             android:layout_width="0dp"
40             android:layout_height="match_parent"
41             android:layout_marginLeft="8dp"
42             android:layout_marginRight="8dp"
43             android:layout_weight="2.5" />
44 
45     </android.support.v7.widget.LinearLayoutCompat>
46 
47 </android.support.v7.widget.LinearLayoutCompat>

 

1.2 布局的逻辑组合

【说明】将逻辑写在onLazyInitView中,加载的时机是在点击分类按钮之后才会加载;

 如果写在onCreateView中,则会打开APP的时候就会加载;

 

【左侧列表】

 

【内容详情页】

 

2. 分类左侧列表数据解析与UI呈现

【说明】将整个data取出,然后分门别类的将其解析成为一个个的bean数据;

 

2.1 数据的转换

 

【增加分类的类别】

 

2.2【完善list列表逻辑】

 

【数据适配器】

 

【list的布局】

 

【点击事件的添加】

 

3.多布局Section列表实现与分类列表点击事件

【contentfragment】

【初始化数据的框架】

【bean的书写】一个id下的内容组成了一个bean;

[单个item的bean]

[id对应的一个contentSection详情数据]

【数据请求】

【适配器的设置】

 

【完善adapter】

 

【适配器的使用】

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM