我的应用程序已终止。尝试调用接口方法' int java.util.List.size()'

时间:2018-02-07 12:59:05

标签: android json android-volley

我的应用已终止

返回hostelList.size这一行在myadapter.java中连续发生错误

我正在创建一个在Recyclerview中显示列表的应用。问题是我在运行应用时出现以下错误并且我正在努力修复它:

E/AndroidRuntime: FATAL EXCEPTION: main
                  Process: com.example.sankar.nestfindersapp, PID: 13821
                  java.lang.NullPointerException: Attempt to invoke interface method 'int java.util.List.size()' on a null object reference
                      at com.example.sankar.nestfindersapp.Java.HostelAdapter.getItemCount(HostelAdapter.java:62)
                      at android.support.v7.widget.RecyclerView.dispatchLayoutStep1(RecyclerView.java:3629)
                      at android.support.v7.widget.RecyclerView.onMeasure(RecyclerView.java:3129)
                      at android.view.View.measure(View.java:19750)
                      at android.support.constraint.ConstraintLayout.internalMeasureChildren(ConstraintLayout.java:934)
                      at android.support.constraint.ConstraintLayout.onMeasure(ConstraintLayout.java:973)
                      at android.view.View.measure(View.java:19750)
                      at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6150)
                      at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
                      at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:139)
                      at android.view.View.measure(View.java:19750)
                      at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6150)
                      at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
                      at android.widget.LinearLayout.measureVertical(LinearLayout.java:758)
                      at android.widget.LinearLayout.onMeasure(LinearLayout.java:640)
                      at android.view.View.measure(View.java:19750)
                      at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6150)
                      at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
                      at android.view.View.measure(View.java:19750)
                      at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6150)
                      at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
                      at android.widget.LinearLayout.measureVertical(LinearLayout.java:758)
                      at android.widget.LinearLayout.onMeasure(LinearLayout.java:640)
                      at android.view.View.measure(View.java:19750)
                      at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6150)
                      at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
                      at com.android.internal.policy.DecorView.onMeasure(DecorView.java:698)
                      at android.view.View.measure(View.java:19750)
                      at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2290)
                      at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1362)
                      at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1611)
                      at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1250)
                      at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6332)
                      at android.view.Choreographer$CallbackRecord.run(Choreographer.java:871)
                      at android.view.Choreographer.doCallbacks(Choreographer.java:683)
                      at android.view.Choreographer.doFrame(Choreographer.java:619)
                      at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:857)
                      at android.os.Handler.handleCallback(Handler.java:751)
                      at android.os.Handler.dispatchMessage(Handler.java:95)
                      at android.os.Looper.loop(Looper.java:154)
                      at android.app.ActivityThread.main(ActivityThread.java:6146)
                      at java.lang.reflect.Method.invoke(Native Method)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
D/HprofFactory: Create HprofDebugEx

0 个答案:

没有答案