问:当添加为NestedScollView的子级时,RecyclerView的行为不正常(将新项目添加到RecyclerView中需要花费2分钟以上的时间来反映)
添加为NestedScollView的子代时,RecyclerView的行为不正确
问题-RecyclerView的notifyItemRangeInserted(int positionStart,int itemCount)方法需要花费2分钟以上的时间才能将新的Items视图添加到窗口中。
一种。当positionStart = 0时,它会立即添加项目,但是随着所有项目再次重新绑定到适配器,图像也会再次重新加载。因此,这不是使用positionStart = 0的最佳实践。
b。当positionStart = currentSize + 1时,添加新添加的项目要花费2分钟以上的时间。
预期的行为-应该在几秒钟内添加视图。
注意-可能正在发生,因为RecyclerView已添加到NestedScrollView中。请研究此问题,因为它限制了开发人员在使用NestedScrollView作为其父视图来实现UI设计时使用此组件。
代码片段:
=================================================== =================
if (productList != null && productList.getData().size() > 0) {
int currentSize = adapter.getItemCount(); // Getting current items Count
adapter.addToProductsList(productList); // Adding new items to the existing list
adapter.notifyItemRangeChanged(currentSize+1, adapter.getItemCount());
=================================================== =================
答:确保在主线程上通知适配器,如果仍然无法解决,请在此处发布整个代码。