你想要的下拉刷新和上拉加载框架

screenshot

Step 1. Add the JitPack repository to your build file
Add it in your root build.gradle at the end of repositories:

    allprojects {
        repositories {
            ...
            maven { url 'https://jitpack.io' }
        }
    }
Step 2. Add the dependency

    dependencies {
            compile 'com.github.yanjiabin:DDPullToRefresh-master:v1.0'
    }
in your xml
    <?xml version="1.0" encoding="utf-8"?>
    <com.yanjiubin.pulltorefreshlibrary.RefreshLayout
        android:id="@+id/refresh_layout"
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <!-- 当然这里我使用的是recyecleview -->
        <android.support.v7.widget.RecyclerView
        android:id="@+id/recycleview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

    </com.yanjiubin.pulltorefreshlibrary.RefreshLayout>
in your code
     refreshLayout = (RefreshLayout) findViewById(R.id.refresh_layout);
        mRecyclerView = (RecyclerView) findViewById(R.id.recycleview);
        mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
        mRecyclerView.setNestedScrollingEnabled(false);
        mAdapter = new TextAdapter();
        mRecyclerView.setAdapter(mAdapter);
        //美团的效果就是new MeiTuanSelfHeaderViewManager(this),基本的下拉效果new NormalSelfHeaderViewManager(this)
        refreshLayout.setSelfHeaderViewManager(new MeiTuanSelfHeaderViewManager(this));
        pageLimitDelegate.attach(refreshLayout, mRecyclerView, mAdapter); //pageLimitDelegate  这个是一个分页管理类
需要注意的是

这里的上拉加载我使用的是 BaseRecyclerViewAdapterHelper 这个库,个人感觉挺不错的,我开发的项目中也都是用的这个库,挺实用的,推荐给大家.
recycleView 搭配BaseRecyclerViewAdapterHelper可以基本上可以解决所有的列表展示.下拉刷新的和上拉加载的逻辑都封装在了pageLimitDelegate这个分页管理类中, 我们只需要请求数据的类 implements PageLimitDelegate.DataProvider 就行了 然后在重写的 loadData(int page) 中去请求数据.

点击这里是我的github地址,如果喜欢不妨来个star

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值