Recyclerview slide appears null pointer exception

Source: Internet
Author: User

<span style= "FONT-SIZE:24PX;" ><strong> Exception Information:</strong></span>
05-07 14:29:49.924:e/messagequeue-jni (16160): java.lang.nullpointerexception05-07 14:29:49.924:e/messagequeue-jni (16160): at Android.support.v7.widget.RecyclerView.computeVerticalScrollOffset (recyclerview.java:1613) 05-07 14:29:49.924:e/messagequeue-jni (16160): at android.view.View.canScrollVertically (view.java:11380) 05-07 14:29:49.924:e/messagequeue-jni (16160): at Android.support.v4.view.ViewCompatICS.canScrollVertically ( viewcompatics.java:35) 05-07 14:29:49.924:e/messagequeue-jni (16160): at android.support.v4.view.viewcompat$ Icsviewcompatimpl.canscrollvertically (viewcompat.java:1253) 05-07 14:29:49.924:e/messagequeue-jni (16160): at Android.support.v4.view.ViewCompat.canScrollVertically (viewcompat.java:1695) 05-07 14:29:49.924:e/ Messagequeue-jni (16160): at Android.support.v4.widget.SwipeRefreshLayout.canChildScrollUp ( swiperefreshlayout.java:646) 05-07 14:29:49.924:e/messagequeue-jni (16160): at Android.support.v4.widget.SwipeRefreshLayout.onInterceptTouchEvent (Swiperefreshlayout.java:660) 05-07 14:29:49.924:e/messagequeue-jni (16160): at Android.view.ViewGroup.dispatchTouchEvent (Viewgroup.java : 1827) 05-07 14:29:49.924:e/messagequeue-jni (16160): at Android.view.ViewGroup.dispatchTransformedTouchEvent ( viewgroup.java:2241) 05-07 14:29:49.924:e/messagequeue-jni (16160): at Android.view.ViewGroup.dispatchTouchEvent ( viewgroup.java:1904) 05-07 14:29:49.924:e/messagequeue-jni (16160): at Android.view.ViewGroup.dispatchTransformedTouchEvent (viewgroup.java:2241) 05-07 14:29:49.924:e/messagequeue-jni ( 16160): At Android.view.ViewGroup.dispatchTouchEvent (viewgroup.java:1904) 05-07 14:29:49.924:e/messagequeue-jni ( 16160): At Android.view.ViewGroup.dispatchTransformedTouchEvent (viewgroup.java:2241) 05-07 14:29:49.924:e/ Messagequeue-jni (16160): at Android.view.ViewGroup.dispatchTouchEvent (viewgroup.java:1904) 05-07 14:29:49.924:e/ Messagequeue-jni (16160): at Android.view.ViewGroup.dispatchTransformedTouchEvent (viewgroup.java:2241) 05-07 14:29:49.924:e/messagequeue-jni (16160): at AndroidOid.view.ViewGroup.dispatchTouchEvent (viewgroup.java:1904) 05-07 14:29:49.924:e/messagequeue-jni (16160): at Android.view.ViewGroup.dispatchTransformedTouchEvent (viewgroup.java:2241) 05-07 14:29:49.924:e/messagequeue-jni ( 16160): At Android.view.ViewGroup.dispatchTouchEvent (viewgroup.java:1904) 05-07 14:29:49.924:e/messagequeue-jni ( 16160): At Android.view.ViewGroup.dispatchTransformedTouchEvent (viewgroup.java:2241) 05-07 14:29:49.924:e/ Messagequeue-jni (16160): at Android.view.ViewGroup.dispatchTouchEvent (viewgroup.java:1904) 05-07 14:29:49.924:e/ Messagequeue-jni (16160): at Com.android.internal.policy.impl.phonewindow$decorview.superdispatchtouchevent ( phonewindow.java:1968) 05-07 14:29:49.924:e/messagequeue-jni (16160): at Com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent (phonewindow.java:1420) 05-07 14:29:49.924:e /messagequeue-jni (16160): at Android.app.Activity.dispatchTouchEvent (activity.java:2428) 05-07 14:29:49.924:e/ Messagequeue-jni (16160): at ANDROID.SUPPORT.V7.VIew. Windowcallbackwrapper.dispatchtouchevent (windowcallbackwrapper.java:60) 05-07 14:29:49.924:e/messagequeue-jni ( 16160): At Android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent (windowcallbackwrapper.java:60) 05-07 14:29:49.924:e/messagequeue-jni (16160): at com.android.internal.policy.impl.phonewindow$ Decorview.dispatchtouchevent (phonewindow.java:1916) 05-07 14:29:49.924:e/messagequeue-jni (16160): at Android.view.View.dispatchPointerEvent (view.java:7437) 05-07 14:29:49.924:e/messagequeue-jni (16160): at Android.view.ViewRootImpl.deliverPointerEvent (viewrootimpl.java:3610) 05-07 14:29:49.924:e/messagequeue-jni ( 16160): At Android.view.ViewRootImpl.deliverInputEvent (viewrootimpl.java:3538) 05-07 14:29:49.924:e/ Messagequeue-jni (16160): at Android.view.ViewRootImpl.doProcessInputEvents (viewrootimpl.java:4790) 05-07 14:29:49.924:e/messagequeue-jni (16160): at Android.view.ViewRootImpl.enqueueInputEvent (viewrootimpl.java:4750) 05-07 14:29:49.924:e/messagequeue-jni (16160): at Android.View. Viewrootimpl$windowinputeventreceiver.oninputevent (viewrootimpl.java:4902) 05-07 14:29:49.924:e/messagequeue-jni (16160): at Android.view.InputEventReceiver.dispatchInputEvent (inputeventreceiver.java:179) 05-07 14:29:49.924:e/ Messagequeue-jni (16160): at Android.os.MessageQueue.nativePollOnce (Native Method) 05-07 14:29:49.924:e/ Messagequeue-jni (16160): at Android.os.MessageQueue.next (messagequeue.java:125) 05-07 14:29:49.924:e/ Messagequeue-jni (16160): at Android.os.Looper.loop (looper.java:140) 05-07 14:29:49.924:e/messagequeue-jni (16160): At Android.app.ActivityThread.main (activitythread.java:5297) 05-07 14:29:49.924:e/messagequeue-jni (16160): at Java.lang.reflect.Method.invokeNative (Native Method) 05-07 14:29:49.924:e/messagequeue-jni (16160): at Java.lang.reflect.Method.invoke (method.java:511) 05-07 14:29:49.924:e/messagequeue-jni (16160): at Com.android.internal.os.zygoteinit$methodandargscaller.run (zygoteinit.java:833) 05-07 14:29:49.924:e/ Messagequeue-jni (16160): at COM.ANDROID.INternal.os.ZygoteInit.main (zygoteinit.java:600) 05-07 14:29:49.924:e/messagequeue-jni (16160): at Dalvik.system.NativeStart.main (Native Method) 05-07 14:29:49.930:e/androidruntime (16160): FATAL exception:main05-07 14:29:49.930:e/androidruntime (16160): java.lang.nullpointerexception05-07 14:29:49.930:e/androidruntime (16160): At Android.support.v7.widget.RecyclerView.computeVerticalScrollOffset (recyclerview.java:1613) 05-07 14:29:49.930: E/androidruntime (16160): at android.view.View.canScrollVertically (view.java:11380) 05-07 14:29:49.930:e/ Androidruntime (16160): at android.support.v4.view.ViewCompatICS.canScrollVertically (viewcompatics.java:35) 05-07 14:29:49.930:e/androidruntime (16160): at android.support.v4.view.viewcompat$ Icsviewcompatimpl.canscrollvertically (viewcompat.java:1253) 05-07 14:29:49.930:e/androidruntime (16160): at Android.support.v4.view.ViewCompat.canScrollVertically (viewcompat.java:1695) 05-07 14:29:49.930:e/androidruntime (16160): at ANDROID.SUPPORT.V4.WIDGET.SWIPEREFREshlayout.canchildscrollup (swiperefreshlayout.java:646) 05-07 14:29:49.930:e/androidruntime (16160): at Android.support.v4.widget.SwipeRefreshLayout.onInterceptTouchEvent (swiperefreshlayout.java:660) 05-07 14:29:49.930:e/androidruntime (16160): at Android.view.ViewGroup.dispatchTouchEvent (viewgroup.java:1827) 05-07 14:29:49.930:e/androidruntime (16160): at Android.view.ViewGroup.dispatchTransformedTouchEvent (Viewgroup.java : 2241) 05-07 14:29:49.930:e/androidruntime (16160): at Android.view.ViewGroup.dispatchTouchEvent (Viewgroup.java : 1904) 05-07 14:29:49.930:e/androidruntime (16160): at Android.view.ViewGroup.dispatchTransformedTouchEvent ( viewgroup.java:2241) 05-07 14:29:49.930:e/androidruntime (16160): at Android.view.ViewGroup.dispatchTouchEvent ( viewgroup.java:1904) 05-07 14:29:49.930:e/androidruntime (16160): at Android.view.ViewGroup.dispatchTransformedTouchEvent (viewgroup.java:2241) 05-07 14:29:49.930:e/androidruntime ( 16160): at Android.view.ViewGroup.dispatchTouchEvent (viewgroup.java:1904) 05-07 14:29:49.930:e/androidruntime (16160): at Android.view.ViewGroup.dispatchTransformedTouchEvent ( viewgroup.java:2241) 05-07 14:29:49.930:e/androidruntime (16160): at Android.view.ViewGroup.dispatchTouchEvent ( viewgroup.java:1904) 05-07 14:29:49.930:e/androidruntime (16160): at Android.view.ViewGroup.dispatchTransformedTouchEvent (viewgroup.java:2241) 05-07 14:29:49.930:e/androidruntime ( 16160): At Android.view.ViewGroup.dispatchTouchEvent (viewgroup.java:1904) 05-07 14:29:49.930:e/androidruntime ( 16160): At Android.view.ViewGroup.dispatchTransformedTouchEvent (viewgroup.java:2241) 05-07 14:29:49.930:e/ Androidruntime (16160): at Android.view.ViewGroup.dispatchTouchEvent (viewgroup.java:1904) 05-07 14:29:49.930:e/ Androidruntime (16160): at Com.android.internal.policy.impl.phonewindow$decorview.superdispatchtouchevent ( phonewindow.java:1968) 05-07 14:29:49.930:e/androidruntime (16160): at Com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent (phonewindow.java:1420) 05-07 14:29:49.930: E/androidruntime (16160): at Android.app.Activity.dispatchTouchEvent (activity.java:2428) 05-07 14:29:49.930:e/ Androidruntime (16160): at Android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent ( WINDOWCALLBACKWRAPPER.JAVA:60) 05-07 14:29:49.930:e/androidruntime (16160): at Android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent (windowcallbackwrapper.java:60) 05-07 14:29:49.930:e/androidruntime (16160): at com.android.internal.policy.impl.phonewindow$ Decorview.dispatchtouchevent (phonewindow.java:1916) 05-07 14:29:49.930:e/androidruntime (16160): at Android.view.View.dispatchPointerEvent (view.java:7437) 05-07 14:29:49.930:e/androidruntime (16160): at Android.view.ViewRootImpl.deliverPointerEvent (viewrootimpl.java:3610) 05-07 14:29:49.930:e/androidruntime (16160) : At Android.view.ViewRootImpl.deliverInputEvent (viewrootimpl.java:3538) 05-07 14:29:49.930:e/androidruntime (16160 ): At Android.view.ViewRootImpl.doProcessInputEvents (viewrootimpl.java:4790) 05-07 14:29:49.930:e/androidRuntime (16160): at Android.view.ViewRootImpl.enqueueInputEvent (viewrootimpl.java:4750) 05-07 14:29:49.930:e/ Androidruntime (16160): at Android.view.viewrootimpl$windowinputeventreceiver.oninputevent (ViewRootImpl.java:4902 ) 05-07 14:29:49.930:e/androidruntime (16160): at Android.view.InputEventReceiver.dispatchInputEvent ( inputeventreceiver.java:179) 05-07 14:29:49.930:e/androidruntime (16160): at Android.os.MessageQueue.nativePollOnce (Native Method) 05-07 14:29:49.930:e/androidruntime (16160): at Android.os.MessageQueue.next (messagequeue.java:125) 05-07 14:29:49.930:e/androidruntime (16160): at Android.os.Looper.loop (looper.java:140) 05-07 14:29:49.930:e/ Androidruntime (16160): at Android.app.ActivityThread.main (activitythread.java:5297) 05-07 14:29:49.930:e/ Androidruntime (16160): at Java.lang.reflect.Method.invokeNative (Native Method) 05-07 14:29:49.930:e/androidruntime ( 16160): At Java.lang.reflect.Method.invoke (method.java:511) 05-07 14:29:49.930:e/androidruntime (16160): at Com.android.inteRnal.os.zygoteinit$methodandargscaller.run (zygoteinit.java:833) 05-07 14:29:49.930:e/androidruntime (16160): at Com.android.internal.os.ZygoteInit.main (zygoteinit.java:600) 05-07 14:29:49.930:e/androidruntime (16160): at Dalvik.system.NativeStart.main (Native Method) 05-07 14:29:50.048:e/apperrordialog (2309): Failed to get Ilowstoragehandle instance05-07 14:29:50.305:e/aee/dumpstate (16293): Copy_process:execv/system/xbin/showmap failed (2), No such file or directory05-07 14:29:50.867:e/aee/dumpstate (16291): Copy_file:copy/proc/gpulog to Sys_gpu_info FAI LED (2), No such file or directory05-07 14:29:52.425:e/aee/dumpstate (16303): Copy_process:execv/system/xbin/procrank FA Iled (2), No such file or directory05-07 14:29:53.023:e/aee/dumpstate (16291): Copy_file:copy/proc/slabinfo to SYS_SLAB_I NFO failed (2), No such file or directory05-07 14:29:53.113:e/aee/dumpstate (16291): Copy_file:copy/sys/kernel/debug/wak Eup_sources to Sys_kernel_wakelocks failed (2), No such file or directory




Courseactivity.java
private void Initview () {... Recyclerview = (Recyclerview) Findviewbyid (r.id.rv_activity_course); Presenter.initcourseslist ();} @Overridepublic void Initcourseslist (list<course> courses) {    adapter = new commonrecyclerviewadapter< Course> (this, r.layout.item_activity_course, courses) {        @Override public        void Convert ( Commondrecyclerviewholder holder, Course Course) {            //...        }    };    Recyclerview.setlayoutmanager (New Linearlayoutmanager (this));    Key point    recyclerview.sethasfixedsize (true);    Recyclerview.setadapter (adapter);}
the key to the error is : Reclerview when initializing the data because of the time-consuming operation, and the layout manager is behind the time-consuming operation, resulting in the process of data loading, the layout manager has not been set, the slide reclerview will report null pointer error. 
The solution is also very simple,  Set the layout manager right after Findviewbyid.  , namely:
= (Recyclerview) Findviewbyid (r.id.  Rv_activity_course);
Recyclerview. Setlayoutmanager (linearlayoutmanager (this));    Key points
。。。。。。 And do other things.

Recyclerview slide appears null pointer exception

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.