Fragment中使用RecyclerView程序闪退的问题

使用viewPager+Fragment的方式构造页面,然后在某个Fagment中使用RecyclerView;异常代码如下:
java.lang.NullPointerException
at android.support.v7.widget.RecyclerView.onMeasure(RecyclerView.java:1764)
at android.view.View.measure(View.java:16935)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:719)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:455)
at android.view.View.measure(View.java:16935)
at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1560)
at android.view.View.measure(View.java:16935)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:719)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:455)
at android.view.View.measure(View.java:16935)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5156)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:135)
at android.view.View.measure(View.java:16935)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5156)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
at android.view.View.measure(View.java:16935)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5156)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at android.view.View.measure(View.java:16935)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5156)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
at android.view.View.measure(View.java:16935)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5156)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2462)
at android.view.View.measure(View.java:16935)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2274)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1153)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1523)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1040)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6147)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
at android.view.Choreographer.doCallbacks(Choreographer.java:574)
at android.view.Choreographer.doFrame(Choreographer.java:544)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5114)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
at dalvik.system.NativeStart.main(Native Method)
0 0-;求解

1个回答

空指针问题要自己好好检查代码了

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐