我的Android应用崩溃报告服务已报告了许多实例:
java.lang.IndexOutOfBoundsException: Invalid index 1, size is 1
at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
at java.util.ArrayList.get(ArrayList.java:308)
at android.widget.HeaderViewListAdapter.isEnabled(HeaderViewListAdapter.java:164)
at android.widget.AbsListView.onInitializeAccessibilityNodeInfoForItem(AbsListView.java:2410)
at android.widget.ListView.onInitializeAccessibilityNodeInfoForItem(ListView.java:3815)
at android.widget.AbsListView$ListItemAccessibilityDelegate.onInitializeAccessibilityNodeInfo(AbsListView.java:2341)
at android.view.View.onInitializeAccessibilityNodeInfo(View.java:5190)
at android.widget.LinearLayout.onInitializeAccessibilityNodeInfo(LinearLayout.java:1784)
at android.view.View.createAccessibilityNodeInfoInternal(View.java:5153)
at android.view.View$AccessibilityDelegate.createAccessibilityNodeInfo(View.java:19459)
at android.widget.AbsListView$ListItemAccessibilityDelegate.createAccessibilityNodeInfo(AbsListView.java:2333)
at android.view.View.createAccessibilityNodeInfo(View.java:5138)
at android.view.AccessibilityInteractionController$AccessibilityNodePrefetcher.prefetchDescendantsOfRealNode(AccessibilityInteractionController.java:811)
at android.view.AccessibilityInteractionController$AccessibilityNodePrefetcher.prefetchDescendantsOfRealNode(AccessibilityInteractionController.java:834)
at android.view.AccessibilityInteractionController$AccessibilityNodePrefetcher.prefetchDescendantsOfRealNode(AccessibilityInteractionController.java:834)
at android.view.AccessibilityInteractionController$AccessibilityNodePrefetcher.prefetchAccessibilityNodeInfos(AccessibilityInteractionController.java:720)
at android.view.AccessibilityInteractionController.findAccessibilityNodeInfoByAccessibilityIdUiThread(AccessibilityInteractionController.java:147)
at android.view.AccessibilityInteractionController.access$300(AccessibilityInteractionController.java:49)
at android.view.AccessibilityInteractionController$PrivateHandler.handleMessage(AccessibilityInteractionController.java:971)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5095)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
at dalvik.system.NativeStart.main(Native Method)
我不知道造成这种情况的原因,我想我会打开一个单独的更集中的问题
答案 0 :(得分:0)
Access element at 0th index
因为您的数组大小为1意味着它包含第0个索引位置的单个元素
java.lang.IndexOutOfBoundsException
因为您的数组只包含一个元素。它位于索引位置0而不是1.您正在访问索引1处的元素,这是不可能的。
尝试访问0索引,但不要超过0.
答案 1 :(得分:0)
您的异常本身告诉您答案。您正在尝试访问元素1,它将是数组的第二个元素,数组大小为1.尝试在访问之前检查数组的大小