ThinkSSL🔒 一键申购 5分钟快速签发 30天无理由退款 购买更放心 广告
[SmartRefreshLayout ](https://github.com/scwang90/SmartRefreshLayout) ## 特点功能: - 支持多点触摸 - 支持嵌套多层的视图结构 Layout (LinearLayout,FrameLayout...) - 支持所有的 View(AbsListView、RecyclerView、WebView....View) - 支持自定义并且已经集成了很多炫酷的 Header 和 Footer. - 支持和ListView的无缝同步滚动 和 CoordinatorLayout 的嵌套滚动 . - 支持自动刷新、自动上拉加载(自动检测列表惯性滚动到底部,而不用手动上拉). - 支持自定义回弹动画的插值器,实现各种炫酷的动画效果. - 支持设置主题来适配任何场景的App,不会出现炫酷但很尴尬的情况. - 支持设多种滑动方式:平移、拉伸、背后固定、顶层固定、全屏 - 支持所有可滚动视图的越界回弹 ## 使用: 1. 声明: ~~~ private RefreshLayout refreshLayout; ~~~ 2. 布局xml: ~~~ <com.scwang.smartrefresh.layout.SmartRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/refreshLayout" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.canyou.redmine.ui.fragment.ProjectsFragment"> <android.support.v7.widget.RecyclerView android:id="@+id/rv_projects" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/darker_gray" /> </com.scwang.smartrefresh.layout.SmartRefreshLayout> ~~~ 3. 绑定: ~~~ refreshLayout = view.findViewById(R.id.refreshLayout); ~~~ 4. 下拉刷新: ~~~ refreshLayout.setOnRefreshListener(new OnRefreshListener() { @Override public void onRefresh(RefreshLayout refreshlayout) { pageIndex = 0; getProjects(pageIndex, pageSize); } }); ~~~ 5. 上拉加载更多: ~~~ refreshLayout.setOnLoadmoreListener(new OnLoadmoreListener() { @Override public void onLoadmore(RefreshLayout refreshlayout) { pageIndex++; getProjects(pageIndex, pageSize); } }); ~~~ 6. 开始刷新: ~~~ refreshLayout.autoRefresh(); ~~~ 7. 结束刷新: ~~~ refreshLayout.finishRefresh(); refreshLayout.finishLoadmore(true); ~~~