我的代码

时间:2015-09-25 21:15:35

标签: android nullpointerexception

我在代码中打开ListActivity时得到Null指针异常,但所有跟踪都不是我的代码。

  

java.lang.NullPointerException at   android.widget.AbsListView.obtainView(AbsListView.java:2606)at   android.widget.ListView.makeAndAddView(ListView.java:1840)at   android.widget.ListView.fillDown(ListView.java:681)at   android.widget.ListView.fillFromTop(ListView.java:742)at   android.widget.ListView.layoutChildren(ListView.java:1661)at   android.widget.AbsListView.onLayout(AbsListView.java:2427)at   android.view.View.layout(View.java:14938)at   android.view.ViewGroup.layout(ViewGroup.java:4601)at   android.widget.RelativeLayout.onLayout(RelativeLayout.java:1021)at   android.view.View.layout(View.java:14938)at   android.view.ViewGroup.layout(ViewGroup.java:4601)at   android.widget.FrameLayout.onLayout(FrameLayout.java:448)at   android.view.View.layout(View.java:14938)at   android.view.ViewGroup.layout(ViewGroup.java:4601)at   android.widget.FrameLayout.onLayout(FrameLayout.java:448)at   android.view.View.layout(View.java:14938)at   android.view.ViewGroup.layout(ViewGroup.java:4601)at   android.widget.LinearLayout.setChildFrame(LinearLayout.java:1694)at   android.widget.LinearLayout.layoutVertical(LinearLayout.java:1552)at   android.widget.LinearLayout.onLayout(LinearLayout.java:1465)at   android.view.View.layout(View.java:14938)at   android.view.ViewGroup.layout(ViewGroup.java:4601)at   android.widget.FrameLayout.onLayout(FrameLayout.java:448)at   android.view.View.layout(View.java:14938)at   android.view.ViewGroup.layout(ViewGroup.java:4601)at   android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2212)at   android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2026)     在android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1236)at   android.view.ViewRootImpl $ TraversalRunnable.run(ViewRootImpl.java:5160)     在   android.view.Choreographer $ CallbackRecord.run(Choreographer.java:791)     在android.view.Choreographer.doCallbacks(Choreographer.java:591)at   android.view.Choreographer.doFrame(Choreographer.java:561)at   android.view.Choreographer $ FrameDisplayEventReceiver.run(Choreographer.java:777)     在android.os.Handler.handleCallback(Handler.java:725)at   android.os.Handler.dispatchMessage(Handler.java:92)at   android.os.Looper.loop(Looper.java:176)at   android.app.ActivityThread.main(ActivityThread.java:5365)at   java.lang.reflect.Method.invokeNative(Native Method)at   java.lang.reflect.Method.invoke(Method.java:511)at   com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1102)     在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)at   dalvik.system.NativeStart.main(原生方法)

我怎么知道错误发生在哪里?

1 个答案:

答案 0 :(得分:0)

正如@iagreen所说,"具体来说,你从你的适配器的getView方法返回null"。

我在getWiew中的自定义适配器中返回null。