NullPointerException at android.widget.AbsListView.obtainView.

使用Adpater更新ListView数据时,莫名奇妙的报了个空指针。内容如下,

java.lang.NullPointerException
at android.widget.AbsListView.obtainView(AbsListView.java:2470)
at android.widget.ListView.makeAndAddView(ListView.java:1775)
at android.widget.ListView.fillDown(ListView.java:678)
at android.widget.ListView.fillFromTop(ListView.java:739)
at android.widget.ListView.layoutChildren(ListView.java:1614)
at android.widget.AbsListView.onLayout(AbsListView.java:2303)
at android.view.View.layout(View.java:14063)
at android.view.ViewGroup.layout(ViewGroup.java:4655)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1655)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1513)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1426)
at android.view.View.layout(View.java:14063)
at android.view.ViewGroup.layout(ViewGroup.java:4655)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:14063)
at android.view.ViewGroup.layout(ViewGroup.java:4655)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:14063)
at android.view.ViewGroup.layout(ViewGroup.java:4655)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:948)
at android.view.View.layout(View.java:14063)
at android.view.ViewGroup.layout(ViewGroup.java:4655)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:14063)
at android.view.ViewGroup.layout(ViewGroup.java:4655)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:948)
at android.view.View.layout(View.java:14063)
at android.view.ViewGroup.layout(ViewGroup.java:4655)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:14063)
at android.view.ViewGroup.layout(ViewGroup.java:4655)

最初为listView设置Adpater时没问题(此时数据库为空List),但更新数据时(重新设置数据List,执行notifyDataSetChanged方法)就报错了。。

后来发现原来,getView返回null。

参考:http://blog.csdn.net/wangbaokangfei/article/details/16967383

你可能感兴趣的:(异常,指针)