好久没用过listview了,最近换工作,一个需求,复用之前的逻辑,沿用了之前的部分listview相关的功能
然后我们这部分功能用户使用频率比较高,需求上线后导致一个listview数组下标越界的bug骤升
排查半天发现某个特定类型的数据可以必现这个问题
之前这个问题出现的概率不高是因为这条数据类型的数据比较少,恰巧我们这边这种类型的数据比较多,因此线上crash率飙升
但仍然死活找不到问题发生的原因,贴一段代码:
java.lang.ArrayIndexOutOfBoundsException: length=47; index=47
at android.widget.AbsListView$RecycleBin.addScrapView(AbsListView.java:7360)
at android.widget.ListView.layoutChildren(ListView.java:1812)
at android.widget.AbsListView$FlingRunnable.run(AbsListView.java:5068)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1057)
at android.view.Choreographer.doCallbacks(Choreographer.java:875)
at android.view.Choreographer.doFrame(Choreographer.java:772)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1042)
at android.os.Handler.handleCallback(Handler.java:888)