本文主要是介绍ProgressDialog.setCanceledOnTouchOutside(false);,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
用ProgressDialog的地方,最好加下这个属性,防止4.0系统出问题。mProgressDialog.setCanceledOnTouchOutside(false);
就是在loading的时候,如果你触摸屏幕其它区域,就会让这个progressDialog消失,然后可能出现崩溃问题,如下:
09-28 11:21:09.476: E/AndroidRuntime(20934): FATAL EXCEPTION: main
09-28 11:21:09.476: E/AndroidRuntime(20934): java.lang.IllegalArgumentException: View not attached to window manager
09-28 11:21:09.476: E/AndroidRuntime(20934): at android.view.WindowManagerImpl.findViewLocked(WindowManagerImpl.java:653)
09-28 11:21:09.476: E/AndroidRuntime(20934): at android.view.WindowManagerImpl.removeView(WindowManagerImpl.java:349)
09-28 11:21:09.476: E/AndroidRuntime(20934): at android.view.WindowManagerImpl$CompatModeWrapper.removeView(WindowManagerImpl.java:160)
09-28 11:21:09.476: E/AndroidRuntime(20934): at android.app.Dialog.dismissDialog(Dialog.java:319)
09-28 11:21:09.476: E/AndroidRuntime(20934): at android.app.Dialog.dismiss(Dialog.java:302)
09-28 11:21:09.476: E/AndroidRuntime(20934): at com.renren.mobile.flok.ui.login.ai.run(Unknown Source)
09-28 11:21:09.476: E/AndroidRuntime(20934): at android.os.Handler.handleCallback(Handler.java:615)
09-28 11:21:09.476: E/AndroidRuntime(20934): at android.os.Handler.dispatchMessage(Handler.java:92)
09-28 11:21:09.476: E/AndroidRuntime(20934): at android.os.Looper.loop(Looper.java:137)
09-28 11:21:09.476: E/AndroidRuntime(20934): at android.app.ActivityThread.main(ActivityThread.java:4899)
09-28 11:21:09.476: E/AndroidRuntime(20934): at java.lang.reflect.Method.invokeNative(Native Method)
09-28 11:21:09.476: E/AndroidRuntime(20934): at java.lang.reflect.Method.invoke(Method.java:511)
09-28 11:21:09.476: E/AndroidRuntime(20934): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
09-28 11:21:09.476: E/AndroidRuntime(20934): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:558)
09-28 11:21:09.476: E/AndroidRuntime(20934): at dalvik.system.NativeStart.main(Native Method)
一个崩溃问题(4.0以上dialog问题)
09-28 11:21:09.476: E/AndroidRuntime(20934): java.lang.IllegalArgumentException: View not attached to window manager
09-28 11:21:09.476: E/AndroidRuntime(20934): at android.view.WindowManagerImpl.findViewLocked(WindowManagerImpl.java:653)
09-28 11:21:09.476: E/AndroidRuntime(20934): at android.view.WindowManagerImpl.removeView(WindowManagerImpl.java:349)
09-28 11:21:09.476: E/AndroidRuntime(20934): at android.view.WindowManagerImpl$CompatModeWrapper.removeView(WindowManagerImpl.java:160)
09-28 11:21:09.476: E/AndroidRuntime(20934): at android.app.Dialog.dismissDialog(Dialog.java:319)
09-28 11:21:09.476: E/AndroidRuntime(20934): at android.app.Dialog.dismiss(Dialog.java:302)
09-28 11:21:09.476: E/AndroidRuntime(20934): at com.renren.mobile.flok.ui.login.ai.run(Unknown Source)
09-28 11:21:09.476: E/AndroidRuntime(20934): at android.os.Handler.handleCallback(Handler.java:615)
09-28 11:21:09.476: E/AndroidRuntime(20934): at android.os.Handler.dispatchMessage(Handler.java:92)
09-28 11:21:09.476: E/AndroidRuntime(20934): at android.os.Looper.loop(Looper.java:137)
09-28 11:21:09.476: E/AndroidRuntime(20934): at android.app.ActivityThread.main(ActivityThread.java:4899)
09-28 11:21:09.476: E/AndroidRuntime(20934): at java.lang.reflect.Method.invokeNative(Native Method)
09-28 11:21:09.476: E/AndroidRuntime(20934): at java.lang.reflect.Method.invoke(Method.java:511)
09-28 11:21:09.476: E/AndroidRuntime(20934): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
09-28 11:21:09.476: E/AndroidRuntime(20934): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:558)
09-28 11:21:09.476: E/AndroidRuntime(20934): at dalvik.system.NativeStart.main(Native Method)
一个崩溃问题(4.0以上dialog问题)
这篇关于ProgressDialog.setCanceledOnTouchOutside(false);的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!