Coder Social home page Coder Social logo

wanliliu / pullupdownrefresh Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 217 KB

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

Java 99.93% Shell 0.07%
android-ultra-pull-to-refresh commonpulltorefresh pulldownrefresh autopulluprefresh

pullupdownrefresh's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.