在我的申请中,我面临一个奇怪的问题。这只发生在Android 6上。它不会在高于6.0的版本上崩溃 我无法添加代码,因为我不知道崩溃究竟在哪里。
有没有办法找出可能存在的问题。我只有一个完整的堆栈跟踪。
我认为这是Android 6中ListView行为的适当变化,但不能完全确定它。
Fatal Exception: java.lang.IndexOutOfBoundsException: Invalid index 1, size is 1
at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
at java.util.ArrayList.get(ArrayList.java:308)
at android.widget.HeaderViewListAdapter.isEnabled(HeaderViewListAdapter.java:164)
at android.widget.ListView.dispatchDraw(ListView.java:3327)
at android.view.View.draw(View.java:16276)
at android.widget.AbsListView.draw(AbsListView.java:4316)
at android.view.View.updateDisplayListIfDirty(View.java:15269)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3599)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3579)
at android.view.View.updateDisplayListIfDirty(View.java:15229)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3599)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3579)
at android.view.View.updateDisplayListIfDirty(View.java:15229)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3599)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3579)
at android.view.View.updateDisplayListIfDirty(View.java:15229)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3599)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3579)
at android.view.View.updateDisplayListIfDirty(View.java:15229)
at android.view.View.draw(View.java:16043)
at android.view.ViewGroup.drawChild(ViewGroup.java:3615)
at android.support.v4.widget.DrawerLayout.drawChild(DrawerLayout.java:1379)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3405)
at android.view.View.draw(View.java:16276)
at android.view.View.updateDisplayListIfDirty(View.java:15269)
at android.view.View.draw(View.java:16043)
at android.view.ViewGroup.drawChild(ViewGroup.java:3615)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3405)
at android.view.View.updateDisplayListIfDirty(View.java:15264)
at android.view.View.draw(View.java:16043)
at android.view.ViewGroup.drawChild(ViewGroup.java:3615)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3405)
at android.view.View.updateDisplayListIfDirty(View.java:15264)
at android.view.View.draw(View.java:16043)
at android.view.ViewGroup.drawChild(ViewGroup.java:3615)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3405)
at android.view.View.updateDisplayListIfDirty(View.java:15264)
at android.view.View.draw(View.java:16043)
at android.view.ViewGroup.drawChild(ViewGroup.java:3615)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3405)
at android.view.View.updateDisplayListIfDirty(View.java:15264)
at android.view.View.draw(View.java:16043)
at android.view.ViewGroup.drawChild(ViewGroup.java:3615)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3405)
at android.view.View.draw(View.java:16276)
at com.android.internal.policy.PhoneWindow$DecorView.draw(PhoneWindow.java:2740)
at android.view.View.updateDisplayListIfDirty(View.java:15269)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:295)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:301)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:336)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:2760)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2564)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2164)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1174)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6241)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:873)
at android.view.Choreographer.doCallbacks(Choreographer.java:676)
at android.view.Choreographer.doFrame(Choreographer.java:606)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:859)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:168)
at android.app.ActivityThread.main(ActivityThread.java:5845)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)
答案 0 :(得分:0)
我找到了解决我问题的方案。
一个选项是刷新列表。所以在这里,清除ArrayList>>从API获取新数据(2-3秒延迟)>>添加到ArrayList>>通知数据集已更改。
问题是我在清除ArrayList后没有立即通知数据集。 (因为它会闪烁)
解决方案:我设法清除数据,添加新数据并同时通知(API调用后)。
仍然想知道为什么它只在Android 6.0上崩溃