2 Star 0 Fork 16

_Newcomer / AdvanceAdapter

forked from zzhoujay / AdvanceAdapter 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

AdvanceAdapter

可以添加Header和Footer的适配与RecyclerView的Adapter

  • 可以添加多个Header和多个Footer
  • 采用的是包裹原本的Adapter的方式,无需修改原本Adapter
  • 同步子Adapter的数据改变事件

注意:在子Adapter中ViewHolder中调用getLayoutPosition()和getAdapterPosition()时会包含外层已添加的Header和Footer

如果已经添加了一个Header,那么在子Adapter中的ViewHolder中调用getAdapterPosition()方法时返回的是该item在子Adapter中的位置+1,这时可以AdvanceAdapter的getHeaderSize方法获取头部的数量并减去,得到正确的位置

使用方法

    NormalAdapter normalAdapter = new NormalAdapter(msgs);
    advanceAdapter = new AdvanceAdapter(normalAdapter);
    View header = getLayoutInflater().inflate(R.layout.header, null);
    View header2 = getLayoutInflater().inflate(R.layout.header2, null);
    View footer = getLayoutInflater().inflate(R.layout.footer, null);
    View footer2 = getLayoutInflater().inflate(R.layout.footer2, null);
    advanceAdapter.addHeader(header);
    advanceAdapter.addHeader(header2);
    advanceAdapter.addFooter(footer);
    advanceAdapter.addFooter(footer2);
    recyclerView.setAdapter(advanceAdapter);

gradle引用方法

    compile 'zhou.widget:advanceadapter:1.0'

运行效果

演示截图 演示截图

by zzhoujay

The MIT License (MIT) Copyright (c) 2015 zzhoujay Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

可以添加Header和Footer的适配于RecyclerView的Adapter 展开 收起
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/lbh/AdvanceAdapter.git
git@gitee.com:lbh/AdvanceAdapter.git
lbh
AdvanceAdapter
AdvanceAdapter
master

搜索帮助

14c37bed 8189591 565d56ea 8189591