简体   繁体   中英

View Pager 2 /Recycler view crash for inconsistency

Getting this crash in my app. Think it's some issue with viewpager2 but couldn't come to conclusion. Tried notifyDatasetchanged() but isnt working with it.

Process: PID: 19449
      **java.lang.IndexOutOfBoundsException:**

     **Inconsistency detected.**


     **Invalid item position 0(offset:-1).state:5 
     androidx.viewpager2.widget.ViewPager2$RecyclerViewImpl{ee4a46e VFED..... ......ID 0,0-1080,1776 
     #7},
     adapter:abc.adapter.ABCPagerAdapter@c87b70f,
     layout:androidx.viewpager2.widget.ViewPager2$LinearLayoutManagerImpl@429b39c,
     context:abc.view.ABCActivity**


    @f6d7d59 at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java)
            at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java)
            at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java)
            at androidx.recyclerview.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java)
            at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java)
            at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java)
            at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java)
            at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep1(RecyclerView.java)
            at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java)
            at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java)
            at android.view.View.layout(View.java
            at android.view.ViewGroup.layout(ViewGroup.java)
            at androidx.viewpager2.widget.ViewPager2.onLayout(ViewPager2.java)
            at android.view.View.layout(View.java)
            at android.view.ViewGroup.layout(ViewGroup.java)
            at android.widget.LinearLayout.setChildFrame(LinearLayout.java)
            at android.widget.LinearLayout.layoutVertical(LinearLayout.java)
            at android.widget.LinearLayout.onLayout(LinearLayout.java:)
            at android.view.View.layout(View.java)
            at android.view.ViewGroup.layout(ViewGroup.java)
            at android.widget.FrameLayout.layoutChildren(FrameLayout.java:)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:)
            at androidx.core.widget.NestedScrollView.onLayout(NestedScrollView.java)
java.lang.IndexOutOfBoundsException:

This Exception came when you try to do something like this:

(A) Add an element in Arraylist or List if List/ArrayList is Full.

(B) When you try to delete an item from empty List/ArrayList

It's good if you simplify your question by mentioning in which action you are getting this error or which class

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM