gpt4 book ai didi

android - java.lang.IndexOutOfBoundsException 在 ListView android

转载 作者:太空狗 更新时间:2023-10-29 12:40:25 25 4
gpt4 key购买 nike

当我设置页脚 View 时,我在 ListView 中遇到了一些奇怪的问题。我正在添加页脚链接以在到达 ListView 中的结束元素时加载更多内容,并在加载时将其删除。 ListViewCursorAdapter 支持。

在 Kitkat 之前,它运行良好,没有任何问题,但是当我在加载更多元素的同时更改 fragment 时,随着 android L 更新,它崩溃并显示以下跟踪:

11-15 17:20:19.532: E/AndroidRuntime(11784): java.lang.IndexOutOfBoundsException: Invalid index 1, size is 1
11-15 17:20:19.532: E/AndroidRuntime(11784): at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
11-15 17:20:19.532: E/AndroidRuntime(11784): at java.util.ArrayList.get(ArrayList.java:308)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.widget.HeaderViewListAdapter.isEnabled(HeaderViewListAdapter.java:164)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.widget.ListView.dispatchDraw(ListView.java:3307)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.View.draw(View.java:15117)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.widget.AbsListView.draw(AbsListView.java:4083)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.View.updateDisplayListIfDirty(View.java:14048)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.View.getDisplayList(View.java:14071)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.View.draw(View.java:14838)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.ViewGroup.drawChild(ViewGroup.java:3404)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3198)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.View.updateDisplayListIfDirty(View.java:14043)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.View.getDisplayList(View.java:14071)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.View.draw(View.java:14838)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.ViewGroup.drawChild(ViewGroup.java:3404)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3198)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.View.draw(View.java:15117)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.View.updateDisplayListIfDirty(View.java:14048)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.View.getDisplayList(View.java:14071)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.View.draw(View.java:14838)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.ViewGroup.drawChild(ViewGroup.java:3404)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3198)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.View.updateDisplayListIfDirty(View.java:14043)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.View.getDisplayList(View.java:14071)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.View.draw(View.java:14838)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.ViewGroup.drawChild(ViewGroup.java:3404)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3198)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.View.updateDisplayListIfDirty(View.java:14043)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.View.getDisplayList(View.java:14071)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.View.draw(View.java:14838)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.ViewGroup.drawChild(ViewGroup.java:3404)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.support.v4.widget.DrawerLayout.drawChild(DrawerLayout.java:1057)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3198)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.View.draw(View.java:15117)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.View.updateDisplayListIfDirty(View.java:14048)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.View.getDisplayList(View.java:14071)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.View.draw(View.java:14838)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.ViewGroup.drawChild(ViewGroup.java:3404)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3198)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.View.updateDisplayListIfDirty(View.java:14043)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.View.getDisplayList(View.java:14071)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.View.draw(View.java:14838)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.ViewGroup.drawChild(ViewGroup.java:3404)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3210)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.View.updateDisplayListIfDirty(View.java:14043)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.View.getDisplayList(View.java:14071)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3388)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3367)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.View.updateDisplayListIfDirty(View.java:14008)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.View.getDisplayList(View.java:14071)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3388)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3367)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.View.updateDisplayListIfDirty(View.java:14008)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.View.getDisplayList(View.java:14071)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3388)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3367)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.View.updateDisplayListIfDirty(View.java:14008)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.View.getDisplayList(View.java:14071)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3388)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3367)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.View.updateDisplayListIfDirty(View.java:14008)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.View.getDisplayList(View.java:14071)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3388)
11-15 17:20:19.532: E/AndroidRuntime(11784): at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3367)

当我删除页脚时,它工作正常。我正在使用 AsyncTask 加载更多内容并将值插入表中,并使用 notifyChange 通知更改。

我不知道我做错了什么。如果有人能告诉我这个问题就好了。

最佳答案

我有完全相同的问题/相同的堆栈跟踪。在我的例子中,我使用 fragment 的支持 v4 库并在添加 fragment 期间使用 setCustomAnimations。当我没有设置 popExit 动画时,问题就停止了。也许这也是你的情况。
我没有找到任何其他解决方法,我认为这只是支持库中的错误。有用的主题 Remove with delayAnimation between fragments .

关于android - java.lang.IndexOutOfBoundsException 在 ListView android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27107510/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com