android listview Caused by: java.lang.ArrayIndexOutOfBoundsException: length=3; index=3
Posted 狂奔的小狮子
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了android listview Caused by: java.lang.ArrayIndexOutOfBoundsException: length=3; index=3相关的知识,希望对你有一定的参考价值。
android listview 适配器在多种类型viewType报错:
Caused by: java.lang.ArrayIndexOutOfBoundsException: length=3; index=3 2 at android.widget.AbsListView$RecycleBin.addScrapView(AbsListView.java:6822) 3 at android.widget.AbsListView.trackMotionScroll(AbsListView.java:5179) 4 at android.widget.AbsListView.scrollIfNeeded(AbsListView.java:3558) 5 at android.widget.AbsListView.onTouchMove(AbsListView.java:3969) 6 at android.widget.AbsListView.onTouchEvent(AbsListView.java:3783) 7 at android.widget.ListView.onTouchEvent(ListView.java:4219) 8 at android.view.View.dispatchTouchEvent(View.java:8556) 9 at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2403) 10 at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2096) 11 at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2409) 12 at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2110) 13 at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2409) 14 at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2110) 15 at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2409) 16 at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2110) 17 at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2409) 18 at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2110) 19 at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2409) 20 at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2110) 21 at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2409) 22 at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2110) 23 at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2409) 24 at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2110) 25 at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2455) 26 at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1756) 27 at android.app.Activity.dispatchTouchEvent(Activity.java:2780) 28 at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2412) 29 at android.view.View.dispatchPointerEvent(View.java:8751) 30 at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4200) 31 at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4066) 32 at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3606) 33 at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3659) 34 at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3625) 35 at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3742) 36 at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3633) 37 at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3799) 38 at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3606) 39 at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3659) 40 at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3625) 41 at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3633) 42 at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3606) 43 at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5901) 44 at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5875) 45 at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5846) 46 at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6012) 47 at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185) 48 at android.view.InputEventReceiver.nativeConsumeBatchedInputEvents(Native Method) 49 at android.view.InputEventReceiver.consumeBatchedInputEvents(InputEventReceiver.java:176) 50 at android.view.ViewRootImpl.doConsumeBatchedInput(ViewRootImpl.java:5962) 51 at android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run(ViewRootImpl.java:6035)
The item view type you are returning from
getItemViewType()
is >= getViewTypeCount()
.
也就是你的viewType的type类型必须从0开始,{0,1,2,3...}这样的.
typecount大于最后一个类型的type即可.
这样就解决了,ListView多种viewType滑动到底,上滑崩溃的现象.
以上是关于android listview Caused by: java.lang.ArrayIndexOutOfBoundsException: length=3; index=3的主要内容,如果未能解决你的问题,请参考以下文章
解决:Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x2
我的Android进阶之旅解决Android Studio报错:Caused by: java.io.StreamCorruptedException: invalid type code: 00
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f070058 android-studio 3
如何在当前活动中将搜索结果保存在 ListView (Android) 中
Caused by: java.lang.NoSuchMethodException: hello.Receiver.receiveMessage([B)