Skip to content

加载更多和List本身分离,ListLoadMoreAction 功能实现自动预加载 PullRefreshLayout 下拉刷新和自动预加载

Notifications You must be signed in to change notification settings

wanliLiu/PullUpDownRefresh

Repository files navigation

PullUpDownRefresh

License Download

Using PullUpDownRefresh in your application

If you are building with Gradle, simply add the following line to the dependencies section of your build.gradle file:

implementation 'com.soli.refresh:pull_up_down:0.0.3'

俗话说,前人栽树后人乘凉,我是在android-Ultra-Pull-To-Refresh下拉基础上,借用CommonPullToRefresh实现的思想,在此基础上,结合自己在实际项目中的经验,总结出来的一个东西。好用,扩展强!

#同时具有下拉刷新和自动预加载

<?xml version="1.0" encoding="utf-8"?>
<com.soli.pullupdownrefresh.PullRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/test_list_view_frame"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ListView
        android:id="@+id/test_list_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@android:color/white" />

</com.soli.pullupdownrefresh.PullRefreshLayout>

分页加载最好设置pagesize,这样更好的实现各种情况下的分页

refreshLayout.setPageSize(pageSize);

设置监听回调

refreshLayout.setRefreshListener(new PullRefreshLayout.onRefrshListener() {
            @Override
            public void onPullDownRefresh() {
                
            }

            @Override
            public void onPullupRefresh(boolean actionFromClick) {

            }
        });

#单个listview上实现自动预加载更多的实现 比如要在ListView GridView(用GridViewWithHeaderAndFooter) 或RecyclerView上实现自动预加载的效果,直接用ListLoadMoreAction就行了,如:

  loadMoreAction = new ListLoadMoreAction();
  loadMoreAction.setPageSize(pageSize);
  
  loadMoreAction.attachToListFor(mListView, actionFromClick -> {
             //实现自动加载跟多的逻辑
  });

还没有弄得问题,空了弄

  • RecyclerView下的GridLayoutManager下,加载跟多的footview显示还有问题,不过这个也简单,只是没有统一写进去

具体参看Demo

About

加载更多和List本身分离,ListLoadMoreAction 功能实现自动预加载 PullRefreshLayout 下拉刷新和自动预加载

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published