删除的ImageView导致某些手机死机 [英] Removing ImageView causes crash on certain phones
问题描述
所以,在我的三星Galaxy S2某种原因(Android版本4.0.4)时,试图从我的RelativeLayout删除的ImageView我得到一个NPE。这里是code线即然
So for some reason on my Samsung Galaxy S2 (Android version 4.0.4) when try to remove a ImageView from my RelativeLayout I get an NPE. Here is the line of code that is ran
mainView.removeView(someImageView)
不过在我的Galaxy Nexus(Android版本4.1.1),它甚至不打嗝。我已经发布下面的NPE。这是不是删除的ImageView的正确方法?基本上我的形象做,我不需要它显示了。任何想法或意见将是巨大的。
However on my Galaxy Nexus (Android version 4.1.1) it does not even hiccup. I have posted the NPE below. Is this not the proper way to remove an ImageView? basically I am done with the image and I don't need it showing any more. Any thoughts or ideas would be great.
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的方法去除
I don't think it has anything to do with the problem but this is being removed on the "onAnimationEnd" method of a translate animation.
推荐答案
尝试设置的ImageView的知名度GONE这样的:
Try to set visibility of the imageView to GONE like:
someImageView.setVisibility(View.GONE);
这篇关于删除的ImageView导致某些手机死机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!