首先是MVP逻辑架构,此处省略
导入下列我们需要的依赖
//MetrialDesign:Design库
implementation 'com.android.support:design:28.+'
//Butterknife:根据反射注入框架
implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
//Brvah:RecyclerView快速开发框架
implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.30'
//SmartRefreshLayout
implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0-alpha-19'
implementation 'com.scwang.smartrefresh:SmartRefreshHeader:1.1.0-alpha-19'
//没有使用特殊Header,可以不加这行
//okgo
//必须使用
implementation 'com.lzy.net:okgo:3.0.4'
implementation 'com.google.code.gson:gson:2.8.5'
//图片加载框架
implementation 'com.github.bumptech.glide:glide:4.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
导入Brvah需要在Gradle下你自己得到包下添加以下代码
maven { url "https://jitpack.io" }
购物车主要的布局分为三部分:
1.activity_main
<LinearLayout 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"
android:orientation="vertical"
tools:context=".ui.activity.MainActivity">
<android.support.v7.widget.Toolbar
android:background="@color/colorAccent"
android:fitsSystemWindows="true"
app:title="@string/toolbar_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<com.scwang.smartrefresh.layout.SmartRefreshLayout
android:id="@+id/srl_container"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_business"
android:layout_width="match_parent"