Git Product home page Git Product logo

swiperefreshrecyclerview's Introduction

SwipeRefreshRecyclerView

概述

这是一个Android Library 带有下拉刷新和上拉加载更多的RecyclerView

截图

效果图

引用依赖库

1.在项目的根目录build.gradle文件添加

allprojects {
    repositories {
	...
	maven { url 'https://jitpack.io' }
    }
}

2.在module的build.gradle引用依赖库

dependencies {
    implementation 'com.github.xiaohu409:SwipeRefreshRecyclerView:1.0'
}

使用教程

1.在module的build.gradle引用依赖库

dependencies {
    implementation 'com.github.xiaohu409:SwipeRefreshRecyclerView:1.0'
}

2.在xml布局文件里使用SwipeRefreshRecyclerView控件

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".SampleActivity">

    <com.github.xiaohu409.swiperefreshrecycler.widget.SwipeRefreshRecyclerView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/swipe_refresh_recycler_view_id"/>
</android.support.constraint.ConstraintLayout>

3.在代码里实例化控件并设置回调、设置布局,绑定数据

//实例化控件
SwipeRefreshRecyclerView recyclerView = findViewById(R.id.swipe_refresh_recycler_view_id);
//设置回调
recyclerView.setLoadDataCallback(new SwipeRefreshRecyclerView.LoadDataCallback() {
    @Override
    public void onPullDownData() {
        //todo 下拉刷新
    }

    @Override
    public void onPullUpData() {
        //todo 上拉加载
    }
});
//设置布局
recyclerView.setLayoutManager(new LinearLayoutManager(this));
//数据源
List<SampleBean.DataBean.NewsBean> newsBeanList = new ArrayList<>();
//实例化适配器
SampleAdapter sampleAdapter = new SampleAdapter(this, newsBeanList);
//设置适配器
recyclerView.setAdapter(sampleAdapter);

Licens

Copyright 2018 xiaohu409

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

swiperefreshrecyclerview's People

Contributors

xiaohu409 avatar

Watchers

 avatar

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.