我使用GridLayoutManager进行recyclelerview,其spansize为1和2
GridLayoutManager.SpanSizeLookup spanSizeLookup = new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
switch (adapter.getItemViewType(position)) {
case TYPE_HEADING:
return 1;
default:
return 2;
}
}
};
RecyclerAdapter adapter = new RecyclerAdapter(mContext, arrItems);
recyclerView.setLayoutManager(gridLayoutManager);
recyclerView.setAdapter(adapter);
Recyclerview完美呈现。但是如果我从recyclerview中删除一个项目,则spansize反转,即TYPE_HEADING的spansize变为2,否则为1。
删除项目的代码。
arrItems.remove(position);
notifyItemRemoved(position);
如何解决此问题