Assume that the previous data is mLastData; the total length position= mLastData.size(); The newly returned data is mNewData, then all the data is mLastData.addAll(mNewData); Use the area refresh of Recyclerview, notifyItemRangeChanged(position+1, mLastData.size());
notifyiteminserted(mcontentlist.size,list.size)//传20
The new n pieces of data are inserted into the front of the list
notifyItemRangeInserted(0, n);
notifyItemInserted(int position)
这个方法是针对单条数据插入更新操作时使用,即在列表某个position插入一条数据,看你想做什么了。我想你需要的是notifyItemRangeInserted(int positionStart, int itemCount)
这个方法,即批量添加,比如你之前已经有20条数据了,上拉加载更多新来的20条数据则是notifyItemRangeInserted(20, 20);
Assume that the previous data is mLastData; the total length position= mLastData.size();
The newly returned data is mNewData, then all the data is mLastData.addAll(mNewData);
Use the area refresh of Recyclerview, notifyItemRangeChanged(position+1, mLastData.size());