Skip to content

Commit

Permalink
添加RecyclerView 的HeadView 和 FooterView
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexMahao committed Sep 26, 2016
1 parent 6fcec5c commit e3d1300
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ public void onBindViewHolder(BaseRecycleAdapter.BaseViewHolder holder, final int

if(isHasHeader&&isHasFooter){
// 有头布局和底部时,向前便宜一个,且最后一个不能绑定数据
if(position==datas.size()+1){
if(position==0 ||position==datas.size()+1){
return;
}
bindData(holder,position-1);
}

if(isHasHeader&&!isHasFooter){
if(position!=0&&isHasHeader&&!isHasFooter){
// 有顶部,但没有底部
bindData(holder,position-1);
}
Expand Down Expand Up @@ -124,15 +124,13 @@ public int getItemViewType(int position) {
if(isHasHeader&&position==0){
return ITEM_TYPE_HEADER;
}

if(isHasHeader&&isHasFooter&&position==datas.size()+1){
// 有头部和底部时,最后底部的应该等于size+!
return ITEM_TYPE_FOOTER;
}else if(!isHasHeader&&isHasFooter&&position==datas.size()){
// 没有头部,有底部,底部索引为size
return ITEM_TYPE_FOOTER;
}

return ITEM_TYPE_NORMAL;
}

Expand Down

0 comments on commit e3d1300

Please sign in to comment.