我正在努力在我的Android应用程序上实现cardView。我按照官方教程,然后将其改编为我的片段类,一切正常。然后我添加了我的自定义cardView图像(我以前保存到本地存储),如果我的卡列表太长,我的应用程序将崩溃与此日志。
03-24 11:24:07.917: E/AndroidRuntime(20763): FATAL EXCEPTION: main
03-24 11:24:07.917: E/AndroidRuntime(20763): java.lang.NullPointerException
03-24 11:24:07.917: E/AndroidRuntime(20763): at android.support.v4.view.ViewCompat$ICSViewCompatImpl.setAccessibilityDelegate(ViewCompat.java:923)
03-24 11:24:07.917: E/AndroidRuntime(20763): at android.support.v4.view.ViewCompat.setAccessibilityDelegate(ViewCompat.java:1343)
03-24 11:24:07.917: E/AndroidRuntime(20763): at android.support.v7.widget.RecyclerView$Recycler.addViewHolderToRecycledViewPool(RecyclerView.java:3900)
03-24 11:24:07.917: E/AndroidRuntime(20763): at android.support.v7.widget.RecyclerView$Recycler.recycleCachedViewAt(RecyclerView.java:3843)
03-24 11:24:07.917: E/AndroidRuntime(20763): at android.support.v7.widget.RecyclerView$Recycler.recycleViewHolderInternal(RecyclerView.java:3880)
03-24 11:24:07.917: E/AndroidRuntime(20763): at android.support.v7.widget.RecyclerView$Recycler.recycleView(RecyclerView.java:3804)
03-24 11:24:07.917: E/AndroidRuntime(20763): at android.support.v7.widget.RecyclerView$LayoutManager.removeAndRecycleViewAt(RecyclerView.java:5529)
03-24 11:24:07.917: E/AndroidRuntime(20763): at android.support.v7.widget.LinearLayoutManager.recycleChildren(LinearLayoutManager.java:1139)
03-24 11:24:07.917: E/AndroidRuntime(20763): at android.support.v7.widget.LinearLayoutManager.recycleViewsFromStart(LinearLayoutManager.java:1180)
03-24 11:24:07.917: E/AndroidRuntime(20763): at android.support.v7.widget.LinearLayoutManager.recycleByLayoutState(LinearLayoutManager.java:1244)
03-24 11:24:07.917: E/AndroidRuntime(20763): at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1268)
03-24 11:24:07.917: E/AndroidRuntime(20763): at android.support.v7.widget.LinearLayoutManager.scrollBy(LinearLayoutManager.java:1102)
03-24 11:24:07.917: E/AndroidRuntime(20763): at android.support.v7.widget.LinearLayoutManager.scrollVerticallyBy(LinearLayoutManager.java:959)
03-24 11:24:07.917: E/AndroidRuntime(20763): at android.support.v7.widget.RecyclerView.scrollByInternal(RecyclerView.java:1047)
03-24 11:24:07.917: E/AndroidRuntime(20763): at android.support.v7.widget.RecyclerView.onTouchEvent(RecyclerView.java:1768)
03-24 11:24:07.917: E/AndroidRuntime(20763): at android.view.View.dispatchTouchEvent(View.java:7205)
03-24 11:24:07.917: E/AndroidRuntime(20763): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2231)
03-24 11:24:07.917: E/AndroidRuntime(20763): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1964)
03-24 11:24:07.917: E/AndroidRuntime(20763): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2237)
03-24 11:24:07.917: E/AndroidRuntime(20763): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1979)
03-24 11:24:07.917: E/AndroidRuntime(20763): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2237)
03-24 11:24:07.917: E/AndroidRuntime(20763): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1979)
03-24 11:24:07.917: E/AndroidRuntime(20763): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2237)
03-24 11:24:07.917: E/AndroidRuntime(20763): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1979)
03-24 11:24:07.917: E/AndroidRuntime(20763): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2237)
03-24 11:24:07.917: E/AndroidRuntime(20763): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1979)
03-24 11:24:07.917: E/AndroidRuntime(20763): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2237)
03-24 11:24:07.917: E/AndroidRuntime(20763): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1979)
03-24 11:24:07.917: E/AndroidRuntime(20763): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2237)
03-24 11:24:07.917: E/AndroidRuntime(20763): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1979)
03-24 11:24:07.917: E/AndroidRuntime(20763): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2237)
03-24 11:24:07.917: E/AndroidRuntime(20763): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1979)
03-24 11:24:07.917: E/AndroidRuntime(20763): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2237)
03-24 11:24:07.917: E/AndroidRuntime(20763): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1979)
03-24 11:24:07.917: E/AndroidRuntime(20763): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2237)
03-24 11:24:07.917: E/AndroidRuntime(20763): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1979)
03-24 11:24:07.917: E/AndroidRuntime(20763): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2237)
03-24 11:24:07.917: E/AndroidRuntime(20763): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1979)
03-24 11:24:07.917: E/AndroidRuntime(20763): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2151)
03-24 11:24:07.917: E/AndroidRuntime(20763): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1480)
03-24 11:24:07.917: E/AndroidRuntime(20763): at android.app.Activity.dispatchTouchEvent(Activity.java:2435)
03-24 11:24:07.917: E/AndroidRuntime(20763): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2099)
03-24 11:24:07.917: E/AndroidRuntime(20763): at android.view.View.dispatchPointerEvent(View.java:7385)
03-24 11:24:07.917: E/AndroidRuntime(20763): at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3398)
03-24 11:24:07.917: E/AndroidRuntime(20763): at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:3331)
03-24 11:24:07.917: E/AndroidRuntime(20763): at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:4422)
03-24 11:24:07.917: E/AndroidRuntime(20763): at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:4401)
03-24 11:24:07.917: E/AndroidRuntime(20763): at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:4493)
03-24 11:24:07.917: E/AndroidRuntime(20763): at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:171)
03-24 11:24:07.917: E/AndroidRuntime(20763): at android.view.InputEventRece
我一直在搜索,但我找不到任何问题的答案。 我在2台设备Lollipop和pre-lollipop上进行了测试,同样的情况发生了,有时Lollipop设备可以处理更大的列表(5个图像项目),但是当我添加更多卡片时它会崩溃。
答案 0 :(得分:1)
我自己找到了解决方案。 我需要更新兼容性库v4和v7