java.lang.Throwable:适配器

时间:2016-02-18 06:53:46

标签: android-recyclerview

这是日志, 此日志显示与itemView的编号一样多的次数。 但我的应用仍然正常运行。

  

ViewGroup:已调用addInArray,这= android.support.v7.widget.RecyclerView {42c4eeb0 VFED .... .F .... ID 0,0-540,876#7f0e0160 app:id / product_update_rec_view} call stack =                                                            java.lang.Throwable:addInArray                                                                在android.view.ViewGroup.addInArray(ViewGroup.java:3786)                                                                在android.view.ViewGroup.addViewInner(ViewGroup.java:3740)                                                                在android.view.ViewGroup.addView(ViewGroup.java:3564)                                                                在android.view.ViewGroup.addView(ViewGroup.java:3509)                                                                在android.support.v7.widget.RecyclerView $ 5.addView(RecyclerView.java:585)                                                                在android.support.v7.widget.ChildHelper.addView(ChildHelper.java:107)                                                                在android.support.v7.widget.RecyclerView $ LayoutManager.addViewInt(RecyclerView.java:6249)                                                                在android.support.v7.widget.RecyclerView $ LayoutManager.addView(RecyclerView.java:6207)                                                                在android.support.v7.widget.RecyclerView $ LayoutManager.addView(RecyclerView.java:6195)                                                                在android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1384)                                                                在android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1333)                                                                在android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:562)                                                                在android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2900)                                                                在android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3071)                                                                在android.view.View.layout(View.java:15132)                                                                在android.view.ViewGroup.layout(ViewGroup.java:4862)                                                                在android.widget.RelativeLayout.onLayout(RelativeLayout.java:1160)                                                                在android.view.View.layout(View.java:15132)                                                                在android.view.ViewGroup.layout(ViewGroup.java:4862)                                                                在android.widget.RelativeLayout.onLayout(RelativeLayout.java:1160)                                                                在android.view.View.layout(View.java:15132)                                                                在android.view.ViewGroup.layout(ViewGroup.java:4862)                                                                在android.support.design.widget.CoordinatorLayout.layoutChild(CoordinatorLayout.java:1037)                                                                在android.support.design.widget.CoordinatorLayout.onLayoutChild(CoordinatorLayout.java:747)                                                                在android.support.design.widget.ViewOffsetBehavior.onLayoutChild(ViewOffsetBehavior.java:42)                                                                在android.support.design.widget.AppBarLayout $ ScrollingViewBehavior.onLayoutChild(AppBarLayout.java:1133)                                                                在android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:760)                                                                在android.view.View.layout(View.java:15132)                                                                在android.view.ViewGroup.layout(ViewGroup.java:4862)                                                                在android.widget.FrameLayout.layoutChildren(FrameLayout.java:515)                                                                在android.widget.FrameLayout.onLayout(FrameLayout.java:450)                                                                在android.view.View.layout(View.java:15132)                                                                在android.view.ViewGroup.layout(ViewGroup.java:4862)                                                                在android.widget.LinearLayout.setChildFrame(LinearLayout.java:1888)                                                                在android.widget.LinearLayout.layoutVertical(LinearLayout.java:1742)                                                                在android.widget.LinearLayout.onLayout(LinearLayout.java:1651)                                                                在android.view.View.layout(View.java:15132)                                                                在android.view.ViewGroup.layout(ViewGroup.java:4862)                                                                在android.widget.FrameLayout.layoutChildren(FrameLayout.java:515)                                                                在android.widget.FrameLayout.onLayout(FrameLayout.java:450)                                                                在android.view.View.layout(View.java:15132)                                                                在android.view.ViewGroup.layout(ViewGroup.java:4862)                                                                在android.widget.LinearLayout.setChildFrame(LinearLayout.java:1888)                                                                在android.widget.LinearLayout.layoutVertical(LinearLayout.java:1742)                                                                在android.widget.LinearLayout.onLayout(LinearLayout.java:1651)                                                                在android.view.View.layout(View.java:15132)                                                                在android.view.ViewGroup.layout(ViewGroup.java:4862)                                                                在android.widget.FrameLayout.layoutChildren(FrameLayout.java:515)                                                                在android.widget.FrameLayout.onLayout(FrameLayout.java:450)                                                                在android.view.View.layout(View.java:15132)                                                                在android.view.ViewGroup.layout(ViewGroup.java:4862)                                                                在android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2323)                                                                在android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2029)                                                                在android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1192)                                                                在android.view.ViewRootImpl $ TraversalRunnable.run(ViewRootImpl.java:6231)                                                                在android.view.Choreographer $ CallbackRecord.run(Choreographer.java:788)                                                                在android.view.Choreographer.doCallbacks(Choreographer.java:591)                                                               在android.view.Choreographer.doFr

1 个答案:

答案 0 :(得分:2)

当您尝试在列表的适配器中使用List<View>时,会发生此异常。

因为arraylist中的视图仍然有引用,因此不能通过垃圾回收来回收,这可能会导致OOM。但是convertView是为可重用性而构建的,所以它可能不会那么容易崩溃。