因此,由于某种原因,在我的三星 Galaxy S2(Android 版本 4.0.4)上尝试从我的 RelativeLayout 中删除 ImageView 时,我得到了 NPE。这是运行的代码行
mainView.removeView(someImageView)
然而,在我的 Galaxy Nexus(Android 版本 4.1.1)上,它甚至没有打嗝。我在下面发布了 NPE。这不是删除 ImageView 的正确方法吗?基本上我已经完成了图像,我不再需要它显示了。任何想法或想法都会很棒。
FATAL EXCEPTION: main
java.lang.NullPointerException
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2488)
at android.view.View.draw(View.java:11150)
at android.view.ViewGroup.drawChild(ViewGroup.java:2887)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
at android.view.View.draw(View.java:11150)
at android.view.ViewGroup.drawChild(ViewGroup.java:2887)
at android.view.View.draw(View.java:11150)
at android.view.ViewGroup.drawChild(ViewGroup.java:2887)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
at android.view.ViewGroup.drawChild(ViewGroup.java:2885)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
at android.view.ViewGroup.drawChild(ViewGroup.java:2885)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
at android.view.View.draw(View.java:11150)
at android.widget.FrameLayout.draw(FrameLayout.java:450)
at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2302)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:2127)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1733)
at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2545)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4507)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
at dalvik.system.NativeStart.main(Native Method)
!@Dumpstate > dumpstate -k -t -n -z -d -o /data/log/dumpstate_app_error
编辑:我认为这与问题没有任何关系,但这已在翻译动画的“onAnimationEnd”方法中被删除。