最近在做和列表或者是Gridview相关显示的出现了一个问题,整理一下思路,分享出来给大家参考一下:
其实不管是LIstView还是GridView都会可能出现,而且原因基本是一样的;
// Short Msg: java.lang.NullPointerException
// Long Msg: java.lang.NullPointerException: Attempt to invoke virtual method ‘int android.view.View.getImportantForAccessibility()‘ on a null object reference // Build Label: Lenovo/passion/passion:5.1.1/LMY47V/VIBEUI_V2.8_1530_5.200.1_ST_P1c72:user/release-keys // Build Changelist: VIBEUI_V2.8_1530_5.200.1_ST_P1c72 // Build Time: 1437513185000 // 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:2363) // at android.widget.GridView.makeAndAddView(GridView.java:1433) // at android.widget.GridView.makeRow(GridView.java:361) // at android.widget.GridView.fillDown(GridView.java:302) // at android.widget.GridView.fillFromTop(GridView.java:437) // at android.widget.GridView.layoutChildren(GridView.java:1276) // at android.widget.AbsListView.onWindowFocusChanged(AbsListView.java:2974) // at android.view.View.dispatchWindowFocusChanged(View.java:8714) // at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:1056) // at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:1060) // at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:1060) // at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:1060) // at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:1060) // at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:1060) // at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:1060) // at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:1060) // at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:1060) // at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:3309) // at android.os.Handler.dispatchMessage(Handler.java:102) // at android.os.Looper.loop(Looper.java:135) // at android.app.ActivityThread.main(ActivityThread.java:5380) // at java.lang.reflect.Method.invoke(Native Method) // at java.lang.reflect.Method.invoke(Method.java:372) // at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:939) // at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:734)
这边添加一个连接,因为我发现和Gallery的出现的一个原因一样的,
原因都是:对应的Adapter的getView方法返回为空,出现的这个空指针现象。
解决方案是一样的:直接看这边
http://blog.csdn.net/sex_34/article/details/47751273
版权声明:本文为博主原创文章,未经博主允许不得转载。
Attempt to invoke virtual method 'int android.view.View.getImportantForAccessibility()'
时间: 2024-10-12 20:05:25