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

前端 未结 26 2519
借酒劲吻你
借酒劲吻你 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:50

    I have same issue with this problem, I'm very tired to search and resolve it. But I have found answer to resolve and exceptions have not been thrown out again.

    public class MyLinearLayoutManager extends LinearLayoutManager 
    {
        public MyLinearLayoutManager(Context context) {
            super(context);
        }
    
        public MyLinearLayoutManager(Context context, int orientation, boolean reverseLayout) {
            super(context, orientation, reverseLayout);
        }
    
        public MyLinearLayoutManager(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
            super(context, attrs, defStyleAttr, defStyleRes);
        }
    
        @Override
        public boolean supportsPredictiveItemAnimations() {
            return false;
        }
    
        @Override
        public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) {
            //override this method and implement code as below
            try {
                super.onLayoutChildren(recycler, state);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    

    I hope this answer will be resolve your problem.

提交回复
热议问题