Android:Log cat错误

时间:2013-12-20 20:56:25

标签: java android eclipse listview logcat

您好我的代码有问题,但我不知道为什么它会显示错误。

 FATAL EXCEPTION: main
 Process: com.musiclist.activity, PID: 6616
 java.lang.NullPointerException
     at android.widget.AbsListView.obtainView(AbsListView.java:2265)
     at android.widget.ListView.measureHeightOfChildren(ListView.java:1263)
     at android.widget.ListView.onMeasure(ListView.java:1175)
     at android.view.View.measure(View.java:16497)
     at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:719)
     at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:455)
     at android.view.View.measure(View.java:16497)
     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
     at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
     at android.view.View.measure(View.java:16497)
     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
     at com.android.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:327)
     at android.view.View.measure(View.java:16497)
     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
     at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
     at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2291)
     at android.view.View.measure(View.java:16497)
     at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1916)
     at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1113)
     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1295)
     at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000)
     at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5670)
     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:5017)
     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:779)
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
     at dalvik.system.NativeStart.main(Native Method)

2 个答案:

答案 0 :(得分:1)

检查您的getView()方法在某些情况下返回null。

类似: Crash in ListView at AbsListView.obtainView for ListActivity

答案 1 :(得分:0)

没有相关代码,因此必须猜出答案:您正在提供ListView ArrayAdapter null作为项目数组。