android listview 适配器在多种类型viewType报错:
java.lang.ArrayIndexOutOfBoundsException: length=4; index=8
at android.widget.AbsListView$RecycleBin.addScrapView(AbsListView.java:7484)
at android.widget.AbsListView.trackMotionScroll(AbsListView.java:5766)
at android.widget.AbsListView$FlingRunnable.run(AbsListView.java:5304)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:896)
at android.view.Choreographer.doCallbacks(Choreographer.java:698)
at android.view.Choreographer.doFrame(Choreographer.java:630)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:882)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5932)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:955)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:816)
The item view type you are returning from
getItemViewType() is >= getViewTypeCount().
也就是你的viewType的type类型从0开始,{0,1,2,3...}这样的.
或者getViewTypeCount大于最后一个类型的type即可.
这样就解决了,ListView多种viewType滑动到底,上滑崩溃的现象.
这个困扰了我下午,后来不想管了,干完别的活又去尝试去解决,多亏又大神的分享才得以解决!
知识就得这样,乐于分享,知识才有意义!