<com.scwang.smartrefresh.layout.SmartRefreshLayout
android:id="@+id/sw_refresh"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.scwang.smartrefresh.layout.header.ClassicsHeader
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<com.scwang.smartrefresh.layout.footer.ClassicsFooter
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
代码 上拉加载更多和下拉刷新可以自定义view,
刷新事件和加载事件这样处理 非常简洁,也支持滑动删除功能
sw_refresh.setOnRefreshListener(new OnRefreshListener() {
@Override
public void onRefresh(RefreshLayout refreshlayout) {
refreshlayout.finishRefresh(2000/*,false*/);//传入false表示刷新失败
}
});
sw_refresh.setOnLoadMoreListener(new OnLoadMoreListener() {
@Override
public void onLoadMore(RefreshLayout refreshlayout) {
refreshlayout.finishLoadMore(2000/*,false*/);//传入false表示加载失败
LoadMoreInfo();
}
});

本文介绍了一个使用SmartRefreshLayout实现上拉加载更多和下拉刷新功能的示例,通过自定义view和简洁的事件处理,展示了刷新和加载事件的实现方式,同时支持滑动删除功能。
2779

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



