一、布局
<?xml version="1.0" encoding="utf-8"?>
<com.scwang.smartrefresh.layout.SmartRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/refreshLayout"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.xwj.lenovo.my_mvp_two.MainActivity">
<android.support.v7.widget.RecyclerView
android:id="@+id/recy_view"
android:layout_width="match_parent"
android:layout_height="match_parent"></android.support.v7.widget.RecyclerView>
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
二、Activity中的具体操作
//SmartRefreshLayout控件的刷新
refreshLayout.setOnRefreshListener(new OnRefreshListener() {
@Override
public void onRefresh(RefreshLayout refreshlayout) {
page = 1;
//重新加载数据
initview();
//3秒以后关闭刷新的视图
refreshlayout.finishRefresh(4000);
}
});
//SmartRefreshLayout控件的加载
refreshLayout.setOnLoadmoreListener(new OnLoadmoreListener() {
@Override
public void onLoadmore(RefreshLayout refreshlayout) {
//页数++ 进行加载下一页
page++;
//重新加载数据
initview();
//3秒以后关闭加载的视图
refreshlayout.finishLoadmore(3000);
}
});
其他的就和mvp平常一样写就行,想详细了解SmartRefreshLayout可以去百度搜索一下更详细的用法。。
本文介绍了如何在布局中集成SmartRefreshLayout组件,并在Activity中进行具体的操作,以实现下拉刷新和上拉加载功能。更多详细用法可自行百度搜索。

2890

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



