ListView random IndexOutOfBoundsException on Froyo
我有一个下载量很大的应用程序,我收到了很多这样的错误:
16783 AndroidRuntime E java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
16783 AndroidRuntime E at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:257)
16783 AndroidRuntime E at java.util.ArrayList.get(ArrayList.java:311)
16783 AndroidRuntime E at android.widget.HeaderViewListAdapter.isEnabled(HeaderViewListAdapter.java:16
4)
16783 AndroidRuntime E at android.widget.ListView.dispatchDrawWithExcessScroll_Default(ListView.java:3
288)
16783 AndroidRuntime E at android.widget.ListView.dispatchDraw(ListView.java:3029)
16783 AndroidRuntime E at android.view.View.draw(View.java:6743)
16783 AndroidRuntime E at android.widget.AbsListView.draw(AbsListView.java:2549)
16783 AndroidRuntime E at android.view.ViewGroup.drawChild(ViewGroup.java:1640)
16783 AndroidRuntime E at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
16783 AndroidRuntime E at android.view.View.draw(View.java:6743)
16783 AndroidRuntime E at android.view.ViewGroup.drawChild(ViewGroup.java:1640)
16783 AndroidRuntime E at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
16783 AndroidRuntime E at android.view.ViewGroup.drawChild(ViewGroup.java:1638)
16783 AndroidRuntime E at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
16783 AndroidRuntime E at android.view.ViewGroup.drawChild(ViewGroup.java:1638)
16783 AndroidRuntime E at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
16783 AndroidRuntime E at android.view.ViewGroup.drawChild(ViewGroup.java:1638)
16783 AndroidRuntime E at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
16783 AndroidRuntime E at android.view.ViewGroup.drawChild(ViewGroup.java:1638)
16783 AndroidRuntime E at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
16783 AndroidRuntime E at android.view.ViewGroup.drawChild(ViewGroup.java:1638)
16783 AndroidRuntime E at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
16783 AndroidRuntime E at android.view.ViewGroup.drawChild(ViewGroup.java:1638)
16783 AndroidRuntime E at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
16783 AndroidRuntime E at android.view.ViewGroup.drawChild(ViewGroup.java:1638)
16783 AndroidRuntime E at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
16783 AndroidRuntime E at android.view.View.draw(View.java:6743)
16783 AndroidRuntime E at android.view.ViewGroup.drawChild(ViewGroup.java:1640)
16783 AndroidRuntime E at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
16783 AndroidRuntime E at android.view.ViewGroup.drawChild(ViewGroup.java:1638)
16783 AndroidRuntime E at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
16783 AndroidRuntime E at android.view.View.draw(View.java:6743)
16783 AndroidRuntime E at android.widget.FrameLayout.draw(FrameLayout.java:352)
16783 AndroidRuntime E at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java
:1885)
16783 AndroidRuntime E at android.view.ViewRoot.draw(ViewRoot.java:1407)
16783 AndroidRuntime E at android.view.ViewRoot.performTraversals(ViewRoot.java:1163)
16783 AndroidRuntime E at android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
16783 AndroidRuntime E at android.os.Handler.dispatchMessage(Handler.java:99)
16783 AndroidRuntime E at android.os.Looper.loop(Looper.java:123)
16783 AndroidRuntime E at android.app.ActivityThread.main(ActivityThread.java:4627)
16783 AndroidRuntime E at java.lang.reflect.Method.invokeNative(Native Method)
16783 AndroidRuntime E at java.lang.reflect.Method.invoke(Method.java:521)
16783 AndroidRuntime E at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:8
58)
16783 AndroidRuntime E at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
16783 AndroidRuntime E at dalvik.system.NativeStart.main(Native Method)
正如您在堆栈跟踪中看到的那样,其中没有一行包含我的代码跟踪。为了重现这一点,我很幸运地找到了一个带有Froyo(2.2 p7)的用户,我只是向下滚动了代码上的一个s。经过一段时间的随机时间,它只是冻结了这个例外。这种情况每次都会在不同的时间发生。ListView
它是一个后面有一个,只是增加了越来越多的行。显然,当我进行“过度滚动”时,我会遇到此错误,但我甚至想不出解决此问题的方法。重现已经足够困难了,但是每次都有近200个用户在线,如果他们继续收到此错误,他们最终将不再使用该应用程序。ListView
EndlessAdapter
任何帮助将不胜感激。
编辑:其他人也遇到了类似的问题。http://groups.google.com/group/cw-android/browse_thread/thread/4739ce05742841da/af59c779e99f5e23?lnk=gst&q=index#af59c779e99f5e23EndlessAdapter
但这不是错。这是机器人的错。EndlessAdapter