android listview Caused by: java.lang.ArrayIndexOutOfBoundsException: length=4; index=8

android listview 適配器在多種類型viewType報(bào)錯(cuò):

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)

解決方案:http://stackoverflow.com/questions/2596547/arrayindexoutofboundsexception-with-custom-android-adapter-for-multiple-views-in

The item view type you are returning from

getItemViewType()?is?>= getViewTypeCount().

也就是你的viewType的type類型從0開始,{0,1,2,3...}這樣的.

或者getViewTypeCount大于最后一個(gè)類型的type即可.

這樣就解決了,ListView多種viewType滑動(dòng)到底,上滑崩潰的現(xiàn)象.

這個(gè)困擾了我下午,后來不想管了,干完別的活又去嘗試去解決,多虧又大神的分享才得以解決!

知識(shí)就得這樣,樂于分享,知識(shí)才有意義!

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • Android 自定義View的各種姿勢(shì)1 Activity的顯示之ViewRootImpl詳解 Activity...
    passiontim閱讀 179,094評(píng)論 25 709
  • afinalAfinal是一個(gè)android的ioc,orm框架 https://github.com/yangf...
    passiontim閱讀 15,877評(píng)論 2 45
  • 品牌對(duì)消費(fèi)者的作用 你到超市里要買瓶水喝,超市里一定有好幾種水品牌,這還不包括碳酸、果汁及功能性飲料。面對(duì)...
    核武子弟閱讀 232評(píng)論 0 0
  • 回想這幾年在淘寶上買的東西,涵蓋了生活消費(fèi)中的好幾個(gè)領(lǐng)域。穿的拎的吃的用的無所不包。真正讓人心儀興奮的物品,細(xì)算下...
    翩翩飛舞閱讀 327評(píng)論 0 1
  • 快速讓客戶買單的思維分解,如何催眠客戶自覺買單呢?銷售的最高境界就是讓對(duì)方感覺到一個(gè)想法是他腦中自己的想法,盡管這...
    紫竹閑云閱讀 683評(píng)論 3 14

友情鏈接更多精彩內(nèi)容