1.问题现象
RecyclerVIEw快速下拉,同时在分页加载数据,当数据很多时,则会出现空指针问题
出错信息如下所示
java.lang.NullPointerException: Attempt to invoke virtual method 'androID.vIEw.VIEwGroup$LayoutParams androID.vIEw.VIEw.getLayoutParams()' on a null object reference at androID.support.v7.Widget.ac.a(Sourcefile:395) at androID.support.v17.leanback.Widget.GrIDLayoutManager.c(Sourcefile:1023) at androID.support.v17.leanback.Widget.GrIDLayoutManager.b(Sourcefile:1587) at androID.support.v17.leanback.Widget.u.b(Sourcefile:388) at androID.support.v17.leanback.Widget.GrIDLayoutManager.A(Sourcefile:1681) at androID.support.v17.leanback.Widget.GrIDLayoutManager.y(Sourcefile:2065) at androID.support.v17.leanback.Widget.GrIDLayoutManager.scrollVerticallyBy(Sourcefile:2010) at androID.support.v7.Widget.RecyclerVIEw$s.run(Sourcefile:4413) at androID.vIEw.Choreographer$CallbackRecord.run(Choreographer.java:775) at androID.vIEw.Choreographer.doCallbacks(Choreographer.java:588) at androID.vIEw.Choreographer.doFrame(Choreographer.java:557) at androID.vIEw.Choreographer$FramedisplayEventReceiver.run(Choreographer.java:761) at androID.os.Handler.handleCallback(Handler.java:739) at androID.os.Handler.dispatchMessage(Handler.java:95) at androID.os.Looper.loop(Looper.java:135) at androID.app.ActivityThread.main(ActivityThread.java:5276) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.androID.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960) at com.androID.internal.os.ZygoteInit.main(ZygoteInit.java:755)2.解决方法
关闭RecyclerVIEw更新动画
RecyclerVIEw.getItemAnimator().setAddDuration(0);RecyclerVIEw.getItemAnimator().setChangeDuration(0);RecyclerVIEw.getItemAnimator().setMoveDuration(0);RecyclerVIEw.getItemAnimator().setRemoveDuration(0);((SimpleItemAnimator) RecyclerVIEw.getItemAnimator()).setSupportsChangeAnimations(false);
总结
以上是内存溢出为你收集整理的RecyclerView列表滑动空指针问题全部内容,希望文章能够帮你解决RecyclerView列表滑动空指针问题所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)