com.com.adapterdialog.MainActivity has leaked window com.android.internal.policy.impl.PhoneWindow$De

在一个ListView的Item中,点击一个Item内的一张图片放大,我在ListView的Adapter中对该图片设置了监听,点击时弹出一个Dialog。然后切屏,报以下错误:

12-24 07:39:41.699: ERROR/WindowManager(325): Activity com.com.adapterdialog.MainActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@44e94f30 that was originally added here
12-24 07:39:41.699: ERROR/WindowManager(325): android.view.WindowLeaked: Activity com.com.adapterdialog.MainActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@44e94f30 that was originally added here
12-24 07:39:41.699: ERROR/WindowManager(325):     at android.view.ViewRoot.<init>(ViewRoot.java:247)
12-24 07:39:41.699: ERROR/WindowManager(325):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
12-24 07:39:41.699: ERROR/WindowManager(325):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
12-24 07:39:41.699: ERROR/WindowManager(325):     at android.view.Window$LocalWindowManager.addView(Window.java:424)
12-24 07:39:41.699: ERROR/WindowManager(325):     at android.app.Dialog.show(Dialog.java:241)
12-24 07:39:41.699: ERROR/WindowManager(325):     at com.com.adapterdialog.adapter.MainAdapter.imageDialog(MainAdapter.java:95)
12-24 07:39:41.699: ERROR/WindowManager(325):     at com.com.adapterdialog.adapter.MainAdapter.access$2(MainAdapter.java:85)
12-24 07:39:41.699: ERROR/WindowManager(325):     at com.com.adapterdialog.adapter.MainAdapter$1.onClick(MainAdapter.java:73)
12-24 07:39:41.699: ERROR/WindowManager(325):     at android.view.View.performClick(View.java:2408)
12-24 07:39:41.699: ERROR/WindowManager(325):     at android.view.View$PerformClick.run(View.java:8816)
12-24 07:39:41.699: ERROR/WindowManager(325):     at android.os.Handler.handleCallback(Handler.java:587)
12-24 07:39:41.699: ERROR/WindowManager(325):     at android.os.Handler.dispatchMessage(Handler.java:92)
12-24 07:39:41.699: ERROR/WindowManager(325):     at android.os.Looper.loop(Looper.java:123)
12-24 07:39:41.699: ERROR/WindowManager(325):     at android.app.ActivityThread.main(ActivityThread.java:4627)
12-24 07:39:41.699: ERROR/WindowManager(325):     at java.lang.reflect.Method.invokeNative(Native Method)
12-24 07:39:41.699: ERROR/WindowManager(325):     at java.lang.reflect.Method.invoke(Method.java:521)
12-24 07:39:41.699: ERROR/WindowManager(325):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
12-24 07:39:41.699: ERROR/WindowManager(325):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
12-24 07:39:41.699: ERROR/WindowManager(325):     at dalvik.system.NativeStart.main(Native Method)

解决方法:
      在定义Activity的地方加上这个属性:android:configChanges="keyboardHidden|orientation"。当在xml文件中配置了android:configChanges="keyboardHidden|orientation"属性,在横紧屏切换的时候不会重新执行Activity的onCreate方法,只是执行onConfigurationChanged方法,否则切换的时候会重新执行onCreate方法

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值