如何防止Android GreedoLayout输出

如何防止Greedo访问超出边界的索引?

以下是堆栈跟踪:

---------开始崩溃

12-28 17:19:22.338 8668-8668 / com.pixerf.android E / AndroidRuntime:致命异常:主要过程:com.pixerf.android,PID:8668 java.lang.IndexOutOfBoundsException:索引:56,尺寸:56在java.util.ArrayList.get(ArrayList.java:411)at com.fivehundredpx.greedolayout.GreedoLayoutSizeCalculator.sizeForChildAtPosition(GreedoLayoutSizeCalculator.java:71)at com.fivehundredpx.greedolayout.GreedoLayoutManager.sizeForChildAtPosition(GreedoLayoutManager.java:282)at com .fivehundredpx.greedolayout.GreedoLayoutManager.preFillGrid(GreedoLayoutManager.java:206)at com.fivehundredpx.greedolayout.GreedoLayoutManager.onLayoutChildren(GreedoLayoutManager.java:122)at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3719 )在android.view.View.layout(View。)上的android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3988)处的android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3436)。 java:17523)at android.view.ViewGroup.layout(ViewGroup.java:5612)at a ndroid.support.v4.widget.SwipeRefreshLayout.onLayout(SwipeRefreshLayout.java:611)在android.view.View.layout(View.java:17523)在android.view.ViewGroup.layout(ViewGroup.java:5612)在安卓.widget.RelativeLayout.onLayout(RelativeLayout.java:1079)at android.view.View.layout(View.java:17523)at android.view.ViewGroup.layout(ViewGroup.java:5612)at android.support.v4。 view.ViewPager.onLayout(ViewPager.java:1769)at android.view.View.layout(View.java:17523)at android.view.ViewGroup.layout(ViewGroup.java:5612)at android.support.design.widget .HeaderScrollingViewBehavior.layoutChild(HeaderScrollingViewBehavior.java:132)at android.support.design.widget.ViewOffsetBehavior.onLayoutChild(ViewOffsetBehavior.java:42)at android.support.design.widget.AppBarLayout $ ScrollingViewBehavior.onLayoutChild(AppBarLayout.java:1361 )在android.view.View.layout(View.java:17523)android.view.ViewGroup.layout(ViewGroup)android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:874) 的.java:5612)在android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)在android.widget.FrameLayout.onLayout(FrameLayout.java:261)在android.view.View.layout(View.java:17523)在android.view.ViewGroup.layout(ViewGroup.java:5612)在android.widget.LinearLayout.setChildFrame(LinearLayout.java:1741)在android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)在android.widget。 LinearLayout.onLayout(LinearLayout.java:1494)在android.view.View.layout(View.java:17523)在android.view.ViewGroup.layout(ViewGroup.java:5612)在android.widget.FrameLayout.layoutChildren(的FrameLayout .java:323)在android.view.ViewGroup.layout(ViewGroup.java:5612)android.view.View.layout(View.java:17523)android.widget.FrameLayout.onLayout(FrameLayout.java:261)在android.widget.LinearLayout.setChildFrame(LinearLayout.java:1741)在android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)在android.widget.LinearLayout.onLayout(LinearLayout.java:1494)在android.view。 View.layout(V iew.java:17523)在android.view.ViewGroup.layout(ViewGroup.java:5612)在android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)在android.widget.FrameLayout.onLayout(FrameLayout.java:261 )在android.view.ViewGroup.layout(ViewGroup.java:5612)上android.view.View.layout(View.java:17523)com.android.internal.policy.DecorView.onLayout(DecorView.java:724)在在android.view android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2342)在android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2069)在android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1246)。 ViewRootImpl $ TraversalRunnable.run(ViewRootImpl.java:6301)在android.view.Choreographer $ CallbackRecord.run(Choreographer.java:871)在android.view.Choreographer.doCallbacks(Choreographer.java:683)在android.view.Choreographer .doFrame(Choreographer.java:619)at android.view.Choreographer $ FrameDisplayEventReceiver.run(Choreographer.java:857)at android.os.Handler.handleCallback(Handler.java:751)12-28 17:19:22。 339 8668-8668 / com.pixerf.android E / AndroidRuntime:at android.os.Handler.dispatchMessage(Handler.java:95)at android.os.Looper.loop(Looper.java:154)at android.app.ActivityThread 。主要(ActivityThread.java:6077)在java.lang.reflect.Method.invoke(本机方法)在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:866)在com.android.internal .os.ZygoteInit.main(ZygoteInit.java:756)


检查你的数组列表或数组大小,然后完成你的任务

if(arraylist.size()>0)
{
//do something 
} 
链接地址: http://www.djcxy.com/p/93169.html

上一篇: How to prevent Android GreedoLayout Out

下一篇: RecyclerView addInArray error when adding