为RecyclerView添加头部和脚部的UI控件:Bookends
                 jopen
                 10年前
            
                    介绍:
为RecyclerView添加头部和脚部的UI控件,可添加多个header和footer 
  运行效果:
 
 使用说明:
eclipse版本下载:http://pan.baidu.com/s/1rYOCe 不包括appcompat和RecyclerView的依赖。
Bookends会封装传递给它的adapter。
其工作原理是在 getItemViewType()的返回值中添加额外的view item类型,将addHeader() 和 addFooter()提供的view映射为头部和脚部。
使用这个类有如下的限制:
-   只对单列的列表有效(比如使用LinearLayoutManager的那种)。 
-   基类adapter不能使用负的view类型,因为Bookends使用负view类型来跟踪头部和脚部。 
-   不能添加超过1000个头部或者脚部。 
例子:
// Create your views, whatever they may be View myHeader = LayoutInflater.from(getContext()).inflate(R.layout.my_header, null); View anotherHeader = LayoutInflater.from(getContext()).inflate(R.layout.another_header, null); View myFooter = LayoutInflater.from(getContext()).inflate(R.layout.my_footer, null); // Add them as headers / footers Bookends<MyAdapter> adapter = new Bookends<MyAdapter>(myAdapter); adapter.addHeader(myHeader); adapter.addHeader(anotherHeader); adapter.addFooter(myFooter);