Open liuyuan1993 opened 5 years ago
可以这样试一试,这边测试没有问题。 修改LRecyclerViewAdapter类。找到onViewAttachedToWindow和onViewDetachedFromWindow方法,作出如下修改:
@Override
public void onViewAttachedToWindow(RecyclerView.ViewHolder holder) {
//增加判断1 if (isHeader(holder.getLayoutPosition()) || isRefreshHeader(holder.getLayoutPosition()) || isFooter(holder.getLayoutPosition())) { super.onViewAttachedToWindow(holder); return; } ViewGroup.LayoutParams lp = holder.itemView.getLayoutParams(); if (lp != null && lp instanceof StaggeredGridLayoutManager.LayoutParams) { if (isHeader(holder.getLayoutPosition()) || isRefreshHeader(holder.getLayoutPosition()) || isFooter(holder.getLayoutPosition())) { StaggeredGridLayoutManager.LayoutParams p = (StaggeredGridLayoutManager.LayoutParams) lp; p.setFullSpan(true); } }
mInnerAdapter.onViewAttachedToWindow(holder);
}
@Override
public void onViewDetachedFromWindow(RecyclerView.ViewHolder holder) {
//增加判断2 if (isHeader(holder.getLayoutPosition()) || isRefreshHeader(holder.getLayoutPosition()) || isFooter(holder.getLayoutPosition())) { super.onViewDetachedFromWindow(holder); return; } mInnerAdapter.onViewDetachedFromWindow(holder); }
发现跟网上开源的MultiType库不能一起用