when i load more data,between last data of refresh and first data of loadmore has no divider,then i scroll the recycleview ,then divider has show,why
wei7785929 opened this issue · 1 comments
wei7785929 commented
when i load more data,between last data of refresh and first data of loadmore has no divider,then i scroll the recycleview ,then divider has show,why
wangxue commented
RecyclerView-FlexibleDivider builder set showLastDivider to false by default,so the last item will have no divider. When app load more data, you called notifyItemRangedInserted and the item which has no divider will not be invalidated.
to fix the problem, here is my suggestions:
- call notifyDatasetChanged when load more data to ensure all items are invalidated
- build divider with showLastDivider
new HorizontalDividerItemDecoration.Builder(this).showLastDivider().build()); - call notifyItemChanged() to invalidate the item which has no divider
final int last = adapter.getItemCount() - 1;
// adaper.notifyItemRangeInserted(last, list.size());
adapter.notifyItemChanged(last);
select one you prefer, i suggest the third one.