java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getImportant

 错误描述:

com.wcyq.gangrong E/CrashReport: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getImportantForAccessibility()' on a null object reference
                                                                    at android.widget.AbsListView.obtainView(AbsListView.java:2603)
                                                                    at android.widget.ListView.makeAndAddView(ListView.java:1920)
                                                                    at android.widget.ListView.fillDown(ListView.java:717)
                                                                    at android.widget.ListView.fillFromTop(ListView.java:778)
                                                                    at android.widget.ListView.layoutChildren(ListView.java:1715)
                                                                    at android.widget.AbsListView.onLayout(AbsListView.java:2319)
                                                                    at android.view.View.layout(View.java:16947)
                                                                    at android.view.ViewGroup.layout(ViewGroup.java:5711)
                                                                    at android.widget.LinearLayout.setChildFrame(LinearLayout.java:2001)
                                                                    at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1844)
                                                                    at android.widget.LinearLayout.onLayout(LinearLayout.java:1753)
                                                                    at android.view.View.layout(View.java:16947)
                                                                    at android.view.ViewGroup.layout(ViewGroup.java:5711)
                                                                    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:396)
                                                                    at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
                                                                    at android.view.View.layout(View.java:16947)
                                                                    at android.view.ViewGroup.layout(ViewGroup.java:5711)
                                                                    at android.widget.LinearLayout.setChildFrame(LinearLayout.java:2001)
                                                                    at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1844)
                                                                    at android.widget.LinearLayout.onLayout(LinearLayout.java:1753)
                                                                    at android.view.View.layout(View.java:16947)
                                                                    at android.view.ViewGroup.layout(ViewGroup.java:5711)
                                                                    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:396)
                                                                    at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
                                                                    at android.view.View.layout(View.java:16947)
                                                                    at android.view.ViewGroup.layout(ViewGroup.java:5711)
                                                                    at android.widget.LinearLayout.setChildFrame(LinearLayout.java:2001)
                                                                    at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1844)
                                                                    at android.widget.LinearLayout.onLayout(LinearLayout.java:1753)
                                                                    at android.view.View.layout(View.java:16947)
                                                                    at android.view.ViewGroup.layout(ViewGroup.java:5711)
                                                                    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:396)
                                                                    at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
                                                                    at android.view.View.layout(View.java:16947)
                                                                    at android.view.ViewGroup.layout(ViewGroup.java:5711)
                                                                    at android.widget.LinearLayout.setChildFrame(LinearLayout.java:2001)
                                                                    at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1844)
                                                                    at android.widget.LinearLayout.onLayout(LinearLayout.java:1753)
                                                                    at android.view.View.layout(View.java:16947)
                                                                    at android.view.ViewGroup.layout(ViewGroup.java:5711)
                                                                    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:396)
                                                                    at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
                                                                    at com.android.internal.policy.PhoneWindow$DecorView.onLayout(PhoneWindow.java:2825)
                                                                    at android.view.View.layout(View.java:16947)
                                                                    at android.view.ViewGroup.layout(ViewGroup.java:5711)
                                                                    at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2551)
                                                                    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2254)
                                                                    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1325)
                                                                    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6756)
                                                                    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
                                                                    at android.view.Choreographer.doCallbacks(Choreographer.java:713)
                                                                    at android.view.Choreographer.doFrame(Choreographer.java:648)
                                                                    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
                                                                    at android.os.Handler.handleCallback(Handler.java:815)
                                                                    at android.os.Handler.dispatchMessage(Handler.java:104)
                                                                    at android.os.Looper.loop(Looper.java:207)
                                                                    at android.app.ActivityThread.main(ActivityThread.java:5856)
                                                                    at java.lang.reflect.Method.invoke(Native Method)
                                                                    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1026)
                                                                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:887)

 原因和解决办法:

    你的adapter 的getView方法返回的是null,没有return值回来,自己检查一下! return convertView

你可能感兴趣的:(安卓Bug)