开发者

NullPointerException while scrolling gallery widget

I have a strange error (NullPointerException) ocurring sometimes while using gallery widget, it occurs only sometimes when scrolling fast in different directions - what is strange, there's none of my classes in the stack trace.

does anyone have any idea what could cause the problem?

10-05 11:54:45.080: ERROR/AndroidRuntime(24935): FATAL EXCEPTION: main
10-05 11:54:45.080: ERROR/AndroidRuntime(24935): java.lang.NullPointerException
10-05 11:54:45.080: ERROR/AndroidRuntime(24935):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
10-05 11:54:45.080: ERROR/AndroidRuntime(24935):     at android.view.View.draw(View.java:6906)
10-05 11:54:45.080: ERROR/AndroidRuntime(24935):     at android.view.ViewGroup.drawChild(ViewGroup.java:1640)
10-05 11:54:45.080: ERROR/AndroidRuntime(24935):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
10-05 11:54:45.080: ERROR/AndroidRuntime(24935):     at android.view.ViewGroup.drawChild(ViewGroup.java:1638)
10-05 11:54:45.080: ERROR/AndroidRuntime(24935):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
10-05 11:54:45.080: ERROR/AndroidRuntime(24935):     at android.view.View.draw(View.java:6906)
10-05 11:54:45.080: ERROR/AndroidRuntime(24935):     at android.widget.FrameLayout.draw(FrameLayout.java:352)
10-05 11:54:45.080: ERROR/AndroidRuntime(24935):     at android.view.ViewGroup.drawChild(ViewGroup.java:1640)
10-05 11:54:45.080: ERROR/AndroidRuntime(24935):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
10-05 11:54:45.080: ERROR/AndroidRuntime(24935):     at android.view.View.draw(View.java:6906)
10-05 11:54:45.080: ERROR/AndroidRuntime(24935):     at android.widget.FrameLayout.draw(FrameLayout.java:352)
10-05 11:54:45.080: ERROR/AndroidRuntime(24935):     at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1868)
10-05 11:54:45.080: ERROR/AndroidRuntime(24935):     at android.view.ViewRoot.draw(ViewRoot.java:1407)
10-05 11:54:45.080: ERROR/AndroidRuntime(24935):     at android.view.ViewRoot.performTraversals(ViewRoot.java:1163)
10-05 11:54:45.080: ERROR/AndroidRuntime(24935):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
10-05 11:54:45.080: ERROR/AndroidRuntime(24935):     at android.os.Handler.dispatchMessage(Handler.java:99)
10-05 11:54:45.080: ERROR/AndroidRuntime(24935):     at android.os.Looper.loop(Looper.java:123)
10-05 11:54:45.080: ERROR/AndroidRuntime(24935):     at android.app.ActivityThread.main(ActivityThread.java:4627)
10-05 11:54:45.080: ERROR/AndroidRuntime(24935):     at java.lang.reflect.Method.invokeNative(Native Method)
10-05 11:54:45.080: ERROR/AndroidRuntime(24935):     at java.lang.reflect.Method.invoke(Met开发者_开发百科hod.java:521)
10-05 11:54:45.080: ERROR/AndroidRuntime(24935):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:876)
10-05 11:54:45.080: ERROR/AndroidRuntime(24935):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:634)
10-05 11:54:45.080: ERROR/AndroidRuntime(24935):     at dalvik.system.NativeStart.main(Native Method)


Yes it happens sometime. It happened with me as well. I wasn't able to find the root cause but what I did as a solution was to wrap the code with try catch and using a !null check solved my problem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜