java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid view holder adapter positionBaseViewHolder{eb6e445 position=8 id=-1, oldPos=15, pLpos:15 scrap [attachedScrap] tmpDetached no parent} androidx.recyclerview.widget.RecyclerView{bd9770c VFED..... ......I. 0,0-1080,2198 #7f0801f0 app:id/vRecycleView}, adapter:com.example.myapplication.NodeSectionAdapter@5786486, layout:androidx.recyclerview.widget.LinearLayoutManager@455ade4, context:com.example.myapplication.MainActivity@430039e
at androidx.recyclerview.widget.RecyclerView$Recycler.validateViewHolderForOffsetPosition(RecyclerView.java:6544)
at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6727)
at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6688)
at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6684)
at androidx.recyclerview.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2362)
at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1662)
at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1622)
at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:687)
at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep1(RecyclerView.java:4550)
at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:4305)
at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:4873)
at android.view.View.layout(View.java:23248)
at android.view.ViewGroup.layout(ViewGroup.java:6540)
at androidx.constraintlayout.widget.ConstraintLayout.onLayout(ConstraintLayout.java:1873)
at android.view.View.layout(View.java:23248)
at android.view.ViewGroup.layout(ViewGroup.java:6540)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
at android.view.View.layout(View.java:23248)
at android.view.ViewGroup.layout(ViewGroup.java:6540)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1829)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1673)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1582)
at android.view.View.layout(View.java:23248)
at android.view.ViewGroup.layout(ViewGroup.java:6540)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
at android.view.View.layout(View.java:23248)
at android.view.ViewGroup.layout(ViewGroup.java:6540)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1829)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1673)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1582)
at android.view.View.layout(View.java:23248)
at android.view.ViewGroup.layout(ViewGroup.java:6540)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
at com.android.internal.policy.DecorView.onLayout(DecorView.java:999)
at android.view.View.layout(View.java:23248)
at android.view.ViewGroup.layout(ViewGroup.java:6540)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:3911)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3369)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2256)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8901)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1131)
at android.view.Choreographer.doCallbacks(Choreographer.java:945)
at android.view.Choreographer.doFrame(Choreographer.java:871)
at android.view.Choreographer$FrameHandler.handleMessage(Choreographer.java:1050)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:257)
2023-11-16 13:56:30.432 27752-27752 AndroidRuntime com.example.myapplication E at android.app.ActivityThread.main(ActivityThread.java:8393)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:631)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1032)
3条答案
按热度按时间atmip9wb1#
数据填充是
private fun getEntity(): MutableList? {
val list: MutableList = ArrayList()
for (i in 0..7) {
val children = mutableListOf()
children.add(ItemNode("2023-11"))
children.add(ItemNode("2023-11"))
children.add(ItemNode("2023-11"))
children.add(ItemNode("2023-11"))
children.add(ItemNode("2023-11"))
children.add(ItemNode("2023-11"))
children.add(ItemNode("2023-11"))
yiytaume2#
你好,大佬,我也遇到同样的问题,如果二级数据一样的话就会出现数组越界,请问解决了吗?
uurity8g3#
我用的版本是3.0.14