Inconsistency detected in RecyclerView, How to change contents of RecyclerView while scrolling

前端 未结 26 2526
借酒劲吻你
借酒劲吻你 2020-12-01 00:59

I\'m using RecyclerView to display name of the items. My row contains single TextView. Item names are stored in List mItemList<

26条回答
  •  忘掉有多难
    2020-12-01 01:55

    I had similar problem while i try to add first item into recyclerView with notifyItemInserted method, so i modified addItem function on my adapter as below and it resolved.

    Weird problem, hope that it'll be fixed soon thoug!

    public void addItem(int position, TableItem item) {
        boolean firstEntry = false;
        if (items.size() == 0) {
            firstEntry = true;
        }
    
        items.add(position, item);
    
        if (firstEntry) {
            notifyDataSetChanged();
        } else {
            notifyItemInserted(position);
        }
    }
    

提交回复
热议问题