GithubHelp home page GithubHelp logo

tom200989 / 34_android-commonrefreshlayout Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mylhyl/android-commonrefreshlayout

0.0 1.0 0.0 8.75 MB

支持AbsListView、RecycleView、WebView的下拉刷新上拉加载

Java 100.00%

34_android-commonrefreshlayout's Introduction

Android-CommonRefreshLayout

基于SwipeRefreshLayout下拉刷新、上拉加载。支持的AbsListViewRecycleViewWebView

####特点

  • 在布局layout中使用,支持xml属性
  • 支持自动下拉刷新,什么用呢?比如进入界面时,只需要调用autoRefresh()方法即可,显示上拉动画同时刷新回调onRefresh将会被调用
  • 上拉加载支持自定义View或设置加载文字、动画、加载完成
  • 轻松设置Adapter空数据视图,默认为TextView支持更文字,也可自定义View
  • 对于简单的界面,例如只有ListView可以继承 SwipeRefreshListFragment 轻松搞定

####效果图

####使用 仔细看listSelector属性,我们是支持的,效果见sample

    <com.mylhyl.crlayout.SwipeRefreshListView xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:crl="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/swipeRefresh"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:listSelector="@drawable/selector_list"
        crl:load_text="数据正在加载中"
        crl:load_indeterminate_drawable="@drawable/footer_progressbar"
        tools:context=".app.ListViewFragment" />

设置上拉加载,更多方法见 LoadConfig

        LoadConfig loadConfig = swipeRefreshListView.getLoadConfig();
        loadConfig.setLoadText("set自定义加载");
        loadConfig.setIndeterminateDrawable(getResources().getDrawable(R.drawable.footer_progressbar));

或 xml属性配置,更多属生见attrs

            crl:load_text="数据正在加载中"
            crl:load_indeterminate_drawable="@drawable/footer_progressbar"

自定义上拉加载

  • 方式一:代码配置
        getSwipeRefreshLayout().setLoadLayoutResource(R.layout.swipe_refresh_footer);
  • 方式二:xml属性配置
        crl:load_layout="@layout/swipe_refresh_footer"
  • 方式三:继承重写getLoadLayoutResource()方法
        public class MySwipeRefreshGridView extends SwipeRefreshGridView {
        
            @Override
            protected int getLoadLayoutResource() {
                return R.layout.swipe_refresh_footer;
            }
        }

设置adapter空数据视图文字

        swipeRefreshListView.setEmptyText("数据呢?");

自定义adapter空数据视图

        ImageView emptyView = new ImageView(getContext());
        emptyView.setImageResource(R.mipmap.empty);
        swipeRefreshGridView.setEmptyView(emptyView);

注册ListView长按事件怎么办?好说好说提供了方法getScrollView(),既然能获取ListViewSwipeRefreshLayout是不是也可以获取到呢?答案是肯定的,方法getSwipeRefreshLayout,你可以随心所欲设置下拉圆圈的颜色、大小等。 关于更多公开方法见 ISwipeRefreshILoadSwipeRefresh

注意事项

setLoadAnimatorsetLoadLayoutResource方法须在setOnListLoadListener之前调用

使用Gradle构建时添加一下依赖即可:

compile 'com.mylhyl:commonrefreshlayout:2.0'

如果使用eclipse

只能clone源码,然后在 eclipse 中用library方式引用

QQ交流群:435173211

更新日志

2.0 UI编辑支持预览

1.9 优化代码

1.8 优化加载更多显示效果

1.7 新增setEnabled禁用下拉刷新

1.6 新增加载完成,命名footer修改为load

1.5 优化SwipeRefreshWebViewautoRefresh方法

1.4 优化SwipeRefreshWebView显示下拉动画

1.3 增加autoRefresh(@ColorRes int... colorResIds)方法,指定动画颜色

1.2 修复滑动到底部会上拉加载多次

1.1 修改为recyclerview-v7:23.4.0

1.0 初始版本

34_android-commonrefreshlayout's People

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.