首页 > 代码库 > NullPointerException at android.widget.AbsListView.obtainView at android.widget.ListView.makeAndAddView

NullPointerException at android.widget.AbsListView.obtainView at android.widget.ListView.makeAndAddView

 

使用ExpandableListView的时候,报如下错。网上搜索发现原来是在CommonNumberQueryAdapter的getGroupView()方法里返回的是null,注意细节哦!!!

 

                                                 

12-19 17:32:41.822: E/AndroidRuntime(1894): FATAL EXCEPTION: main
12-19 17:32:41.822: E/AndroidRuntime(1894): java.lang.NullPointerException
12-19 17:32:41.822: E/AndroidRuntime(1894): at android.widget.AbsListView.obtainView(AbsListView.java:2269)
12-19 17:32:41.822: E/AndroidRuntime(1894): at android.widget.ListView.makeAndAddView(ListView.java:1769)
12-19 17:32:41.822: E/AndroidRuntime(1894): at android.widget.ListView.fillDown(ListView.java:672)
12-19 17:32:41.822: E/AndroidRuntime(1894): at android.widget.ListView.fillSpecific(ListView.java:1330)
12-19 17:32:41.822: E/AndroidRuntime(1894): at android.widget.ListView.layoutChildren(ListView.java:1600)
12-19 17:32:41.822: E/AndroidRuntime(1894): at android.widget.AbsListView.onLayout(AbsListView.java:2102)
12-19 17:32:41.822: E/AndroidRuntime(1894): at android.view.View.layout(View.java:13754)
12-19 17:32:41.822: E/AndroidRuntime(1894): at android.view.ViewGroup.layout(ViewGroup.java:4362)
12-19 17:32:41.822: E/AndroidRuntime(1894): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1649)
12-19 17:32:41.822: E/AndroidRuntime(1894): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1507)
12-19 17:32:41.822: E/AndroidRuntime(1894): at android.widget.LinearLayout.onLayout(LinearLayout.java:1420)
12-19 17:32:41.822: E/AndroidRuntime(1894): at android.view.View.layout(View.java:13754)
12-19 17:32:41.822: E/AndroidRuntime(1894): at android.view.ViewGroup.layout(ViewGroup.java:4362)
12-19 17:32:41.822: E/AndroidRuntime(1894): at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
12-19 17:32:41.822: E/AndroidRuntime(1894): at android.view.View.layout(View.java:13754)
12-19 17:32:41.822: E/AndroidRuntime(1894): at android.view.ViewGroup.layout(ViewGroup.java:4362)
12-19 17:32:41.822: E/AndroidRuntime(1894): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1649)
12-19 17:32:41.822: E/AndroidRuntime(1894): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1507)
12-19 17:32:41.822: E/AndroidRuntime(1894): at android.widget.LinearLayout.onLayout(LinearLayout.java:1420)
12-19 17:32:41.822: E/AndroidRuntime(1894): at android.view.View.layout(View.java:13754)
12-19 17:32:41.822: E/AndroidRuntime(1894): at android.view.ViewGroup.layout(ViewGroup.java:4362)
12-19 17:32:41.822: E/AndroidRuntime(1894): at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
12-19 17:32:41.822: E/AndroidRuntime(1894): at android.view.View.layout(View.java:13754)
12-19 17:32:41.822: E/AndroidRuntime(1894): at android.view.ViewGroup.layout(ViewGroup.java:4362)
12-19 17:32:41.822: E/AndroidRuntime(1894): at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1866)
12-19 17:32:41.822: E/AndroidRuntime(1894): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1687)
12-19 17:32:41.822: E/AndroidRuntime(1894): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:998)
12-19 17:32:41.822: E/AndroidRuntime(1894): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4212)
12-19 17:32:41.822: E/AndroidRuntime(1894): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
12-19 17:32:41.822: E/AndroidRuntime(1894): at android.view.Choreographer.doCallbacks(Choreographer.java:555)
12-19 17:32:41.822: E/AndroidRuntime(1894): at android.view.Choreographer.doFrame(Choreographer.java:525)
12-19 17:32:41.822: E/AndroidRuntime(1894): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
12-19 17:32:41.822: E/AndroidRuntime(1894): at android.os.Handler.handleCallback(Handler.java:615)
12-19 17:32:41.822: E/AndroidRuntime(1894): at android.os.Handler.dispatchMessage(Handler.java:92)
12-19 17:32:41.822: E/AndroidRuntime(1894): at android.os.Looper.loop(Looper.java:137)
12-19 17:32:41.822: E/AndroidRuntime(1894): at android.app.ActivityThread.main(ActivityThread.java:4745)
12-19 17:32:41.822: E/AndroidRuntime(1894): at java.lang.reflect.Method.invokeNative(Native Method)
12-19 17:32:41.822: E/AndroidRuntime(1894): at java.lang.reflect.Method.invoke(Method.java:511)
12-19 17:32:41.822: E/AndroidRuntime(1894): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
12-19 17:32:41.822: E/AndroidRuntime(1894): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
12-19 17:32:41.822: E/AndroidRuntime(1894): at dalvik.system.NativeStart.main(Native Method)

NullPointerException at android.widget.AbsListView.obtainView at android.widget.ListView.makeAndAddView