- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
所以,我不明白为什么会出现这个错误:
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/
我有一个随机出现的 ArrayIndexOutOfBoundsException。它似乎是在我的 notifyDataSetChanged(); 期间发生的,因为错误是如此随机,所以很难准确指出它发生
所以,我不明白为什么会出现这个错误: 04-06 17:51:10.252: E/AndroidRuntime(10745): FATAL EXCEPTION: main 04-06 17:51:10
我有一个我正在使用的分段适配器,但是我正在尝试修改它,以便使用 if (section.adapter.getCount() > 0) 使这些部分在它们为空时不会出现。我有以下类(class): ab
我是一名优秀的程序员,十分优秀!