vlayout 上滑加载更多问题
来源:互联网 发布:螺栓连接计算软件 编辑:程序博客网 时间:2024/06/08 11:09
LoadMoreWrapper
在不改动 RecyclerView 原有 adapter 的情况下,使其拥有加载更多功能和自定义底部视图。
- 支持当 item 未铺满屏幕的时候仍能够加载更多
- 支持自定义加载视图
- 当 layoutManager 为 Grid 和 StaggeredGrid 的时候, 加载更多视图 footerView 仍占据一行
- 支持设置是否显示没有更多视图,可自定义
- 支持vlayout library分页(注:这个功能不能以插件方式引入到项目中,只能手动引入。使用方式请参考 VLayoutRefreshAndLoadMoreActivity)
Installation
JCenter:
add the dependency to your build.gradle:
compile 'com.github.nukc:loadmorewrapper:1.6.2'
JitPack:
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.nukc:LoadMoreWrapper:v1.6.2' }
Usage
//the adapter is the original (这个 adapter 是原有的, 不改动它) LoadMoreWrapper.with(adapter) .setFooterView(...) // view or layout resource .setShowNoMoreEnabled(true) // enable show NoMoreView,default false .setListener(new LoadMoreAdapter.OnLoadMoreListener() { @Override public void onLoadMore(LoadMoreAdapter.Enabled enabled) { // do something // you can enabled.setLoadMoreEnabled(false) when do not need load more }) .into(recyclerView);
or
in the original adapter: demo
private static class AnotherAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { private LoadMoreWrapper mWrapper; // code.. @Override public void onAttachedToRecyclerView(RecyclerView recyclerView) { super.onAttachedToRecyclerView(recyclerView); mWrapper = LoadMoreWrapper.with(this); mWrapper.setListener( new LoadMoreAdapter.OnLoadMoreListener() { @Override public void onLoadMore(LoadMoreAdapter.Enabled enabled) { // do something } }) .setShowNoMoreEnabled(true) .into(recyclerView); } }
注意:当加载完全部后且已 setLoadMoreEnabled(false),但如果由于生命周期或其他问题而导致 View 重建,mLoadMoreEnabled 依然为 true。
这时候应该需要保存 mLoadMoreEnabled 的状态,如果是 ViewPager + Fragment,可以使用 setOffscreenPageLimit 进行解决。
感谢
alibaba / vlayout
nukc / LoadMoreWrapper
License
Copyright 2016, 2017 nukcLicensed 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.0Unless required by applicable law or agreed to in writing, softwaredistributed 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 andlimitations under the License.
阅读全文
0 0
- vlayout 上滑加载更多问题
- ionic上拉加载更多问题
- Android 下拉刷新,上滑加载更多
- 上拉加载更多
- 上拉加载更多
- 上拉加载更多
- 上拉加载更多
- PullToRefreshListView的下拉刷新上拉加载更多问题
- listview 上拉加载更多
- ListView上拉加载更多
- ListView上拉加载更多
- ionic 上拉加载更多
- Android上拉加载更多
- android 上拉加载更多
- 上拉到底部加载更多
- 上拉加载更多数据
- RecyclerView 上拉加载更多
- vue上拉加载更多
- HDFS_块
- CENTOS 安装 ElasticSearch
- 告别“选择困难症” | 康普推出《高效互联的数据中心》电子书
- Wireshark基本介绍和学习TCP三次握手
- 极光推送分类推送 最新别名设置ios
- vlayout 上滑加载更多问题
- 校正 information_schema.tables 中表行数
- javaEE 中jdbc加载数据库驱动失败
- Netty学习(五)—IdleStateHandler心跳机制
- Error:(6) Error parsing XML: XML or text declaration not at start of entity
- java8特性:Collectors.groupingBy进行分组、排序等操作 (二)
- HTML 3D表白爱心
- 【NOIP2017】棋盘
- Spring控制反转/依赖注入概念解析