gpt4 book ai didi

Android AbsListView$RecycleBin.addScrapView(AbsListView.java :6588)

转载 作者:行者123 更新时间:2023-12-02 14:12:31 25 4
gpt4 key购买 nike

所以,我不明白为什么会出现这个错误:

04-06 17:51:10.252: E/AndroidRuntime(10745): FATAL EXCEPTION: main 04-06 17:51:10.252: E/AndroidRuntime(10745): Process: com.stm.classlife, PID: 10745 04-06 17:51:10.252: E/AndroidRuntime(10745): java.lang.ArrayIndexOutOfBoundsException: length=2; index=2 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.widget.AbsListView$RecycleBin.addScrapView(AbsListView.java:6588) 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.widget.ListView.layoutChildren(ListView.java:1632) 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.widget.AbsListView.onTouchMove(AbsListView.java:3763) 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.widget.AbsListView.onTouchEvent(AbsListView.java:3632) 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.view.View.dispatchTouchEvent(View.java:8471) 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2399) 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2092) 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405) 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106) 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405) 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106) 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405) 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106) 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405) 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106) 04-06 17:51:10.252: E/AndroidRuntime(10745): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2369) 04-06 17:51:10.252: E/AndroidRuntime(10745): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1719) 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.app.Activity.dispatchTouchEvent(Activity.java:2742) 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.support.v7.app.ActionBarActivityDelegateICS$WindowCallbackWrapper.dispatchTouchEvent(ActionBarActivityDelegateICS.java:268) 04-06 17:51:10.252: E/AndroidRuntime(10745): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2330) 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.view.View.dispatchPointerEvent(View.java:8666) 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4123) 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3989) 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3544) 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3597) 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3563) 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3680) 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3571) 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3737) 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3544) 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3597) 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3563) 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3571) 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3544) 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5807) 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5781) 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5752) 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:5897) 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185) 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.view.InputEventReceiver.nativeConsumeBatchedInputEvents(Native Method) 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.view.InputEventReceiver.consumeBatchedInputEvents(InputEventReceiver.java:176) 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.view.ViewRootImpl.doConsumeBatchedInput(ViewRootImpl.java:5868) 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run(ViewRootImpl.java:5920) 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767) 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.view.Choreographer.doCallbacks(Choreographer.java:580) 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.view.Choreographer.doFrame(Choreographer.java:548) 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753) 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.os.Handler.handleCallback(Handler.java:739) 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.os.Handler.dispatchMessage(Handler.java:95) 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.os.Looper.loop(Looper.java:135) 04-06 17:51:10.252: E/AndroidRuntime(10745): at android.app.ActivityThread.main(ActivityThread.java:5254) 04-06 17:51:10.252: E/AndroidRuntime(10745): at java.lang.reflect.Method.invoke(Native Method) 04-06 17:51:10.252: E/AndroidRuntime(10745): at java.lang.reflect.Meth

有人知道怎么解决吗?

最佳答案

从您的崩溃日志中,这里是相关行:

android.widget.AbsListView$RecycleBin.addScrapView(AbsListView.java:6588)

if (mViewTypeCount == 1) {
mCurrentScrap.add(scrap);
} else {
mScrapViews[viewType].add(scrap);
}

本质上,当您将 ListView 项滚动到屏幕之外并且回收器尝试回收它时,就会发生这种情况。此 View 的 View 类型(由 android.widget.Adapter#getItemViewType(int) 返回)抛出 java.lang.ArrayIndexOutOfBoundsException: length=2;索引=2

参见android.widget.Adapter#getItemViewType(int) :

Note: Integers must be in the range 0 to getViewTypeCount() - 1.

我也遇到了同样的问题。检查 getItemViewType(int) 的重写方法,并确保返回连续的零索引号。由于您的 getViewTypeCount() 方法返回 2,因此项目类型常量必须为 0 和 1。

关于Android AbsListView$RecycleBin.addScrapView(AbsListView.java :6588),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29471764/

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