使用AlertDialog.Builder点击确定需要进行一个网络操作,结果报错
StartActivity has leaked window com.android.internal.policy.PhoneWindow$DecorView{4288226 V.E...... R.....I. 0,0-1026,476} that was originally added here
at android.view.ViewRootImpl.<init>(ViewRootImpl.java:368)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:299)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:85)
上网查了,要把alert给dismiss,根本不行,AlertDialog.Builder本身没有dismiss方法,并且点击效果本身就是取消了窗口的显示,,,,这个要怎么做?
阿神2017-04-18 09:23:45
AlertDialog.Builder This class generates AlertDialog based on configuration.
AlertDialog can only be displayed and has the dimiss method.
The result generated by Builder is Builder. If the create or show method is not called, no AlertDialog will be generated.
巴扎黑2017-04-18 09:23:45
Same as above, the description is a bit vague, not sure what you want to say
高洛峰2017-04-18 09:23:45
Form leakage, it should be that the dialog still holds the Activity's Context, and you closed the Activity directly. Please post the specific code
ringa_lee2017-04-18 09:23:45
Builder is just a parameter to construct the class.
Call builder's build() to actually construct an instance of the class.
In your case, you need to declare a Dialog to receive it, so that you have a chance to call the dismiss() method.
怪我咯2017-04-18 09:23:45
You must first build.create() to create an alertdialog, and then you can use alertdialog.show() and alertdialog.dismiss()
黄舟2017-04-18 09:23:45
Is the context you pass in the activity's context or the application's context? If it is the application's context, a similar error will occur. You need to give the dialog an attached window before it can be displayed