问题描述
所以,我不明白为什么会出现此错误:
So, I don't understand why appear this error:
有人知道如何解决吗?
推荐答案
在您的崩溃日志中,以下是相关行:
From your crash logs here is the relevant line:
if (mViewTypeCount == 1) {
mCurrentScrap.add(scrap);
} else {
mScrapViews[viewType].add(scrap);
}
基本上,当您在屏幕外滚动列表视图项目并且回收者尝试回收该项目时,会发生这种情况.由android.widget.Adapter#getItemViewType(int)
返回的该视图的视图类型将抛出您的java.lang.ArrayIndexOutOfBoundsException: length=2; index=2
.
Essentially this happens when you scroll a list view item off-screen and the recycler tries to reclaim it. View type for this view, as returned by android.widget.Adapter#getItemViewType(int)
, is throwing your java.lang.ArrayIndexOutOfBoundsException: length=2; index=2
.
请参见 android.widget.Adapter#getItemViewType(int) :
我有同样的问题.检查getItemViewType(int)
的替代方法,并确保您返回的是连续的零索引数字.由于您的getViewTypeCount()
方法返回2,因此您的商品类型常量必须为0和1.
I had the same problem. Check your override method for getItemViewType(int)
, and ensure that you're returning consecutive zero-index numbers. Since your getViewTypeCount()
method is returning 2, then your constants for item type must be 0 and 1.
这篇关于Android AbsListView $ RecycleBin.addScrapView(AbsListView.java:6588)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!