Skip to content
This repository has been archived by the owner on Jul 14, 2021. It is now read-only.

下拉刷新出现:Attempt to read from field 'android.view.View android.support.v7.widget.RecyclerView$ViewHolder.itemView' on a null object reference #474

Closed
tangbei opened this issue Oct 15, 2019 · 2 comments

Comments

@tangbei
Copy link

tangbei commented Oct 15, 2019

Android: 7.0
Manufacturer: HUAWEI
Model: HUAWEI NXT-AL10
CrashReporter Key: C1ED375F-55D1-2DC8-8291-28A8826E445C8A854826
Date: Tue Oct 15 15:24:42 GMT+08:00 2019

java.lang.NullPointerException: Attempt to read from field 'android.view.View android.support.v7.widget.RecyclerView$ViewHolder.itemView' on a null object reference
at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:6795)
at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5975)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5858)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5854)
at com.alibaba.android.vlayout.ExposeLinearLayoutManagerEx$LayoutState.next(ExposeLinearLayoutManagerEx.java:1629)
at com.alibaba.android.vlayout.VirtualLayoutManager$LayoutStateWrapper.next(VirtualLayoutManager.java:1043)
at com.alibaba.android.vlayout.layout.BaseLayoutHelper.nextView(BaseLayoutHelper.java:116)
at com.alibaba.android.vlayout.layout.LinearLayoutHelper.layoutViews(LinearLayoutHelper.java:88)
at com.alibaba.android.vlayout.layout.BaseLayoutHelper.doLayout(BaseLayoutHelper.java:318)
at com.alibaba.android.vlayout.VirtualLayoutManager.layoutChunk(VirtualLayoutManager.java:639)
at com.alibaba.android.vlayout.ExposeLinearLayoutManagerEx.fill(ExposeLinearLayoutManagerEx.java:1162)
at com.alibaba.android.vlayout.ExposeLinearLayoutManagerEx.onLayoutChildren(ExposeLinearLayoutManagerEx.java:365)
at com.alibaba.android.vlayout.VirtualLayoutManager.onLayoutChildren(VirtualLayoutManager.java:463)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3924)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3641)
at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:4194)
at android.view.View.layout(View.java:17684)
at android.view.ViewGroup.layout(ViewGroup.java:5631)
at com.scwang.smartrefresh.layout.SmartRefreshLayout.onLayout(SmartRefreshLayout.java:655)
at android.view.View.layout(View.java:17684)
at android.view.ViewGroup.layout(ViewGroup.java:5631)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1762)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1606)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1515)
at android.view.View.layout(View.java:17684)
at android.view.ViewGroup.layout(ViewGroup.java:5631)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:325)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:17684)
at android.view.ViewGroup.layout(ViewGroup.java:5631)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1762)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1606)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1515)
at android.view.View.layout(View.java:17684)
at android.view.ViewGroup.layout(ViewGroup.java:5631)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:325)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:17684)
at android.view.ViewGroup.layout(ViewGroup.java:5631)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1762)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1606)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1515)
at android.view.View.layout(View.java:17684)
at android.view.ViewGroup.layout(ViewGroup.java:5631)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:325)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at com.android.internal.policy.DecorView.onLayout(DecorView.java:774)
at android.view.View.layout(View.java:17684)
at android.view.ViewGroup.layout(ViewGroup.java:5631)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2511)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2226)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1364)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6757)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:923)
at android.view.Choreographer.doCallbacks(Choreographer.java:735)
at android.view.Choreographer.doFrame(Choreographer.java:667)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:909)
at android.os.Handler.handleCallback(Handler.java:755)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:6524)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:941)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:831)

下拉刷新时出现NullPointerException情况,这是什么原因引起的啊?

@tangbei
Copy link
Author

tangbei commented Oct 16, 2019

image
是因为在此刷新时,在onCreateViewHolder中出现 返回null的情况产生的。

@tangbei tangbei closed this as completed Oct 16, 2019
@AndoridZgc
Copy link

@tangbei 这玩意你咋解决的 怎么关闭了?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants