使用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方法,并且点击效果本身就是取消了窗口的显示,,,,这个要怎么做?
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.
I suggest you post the code, it’s hard to understand!
Same as above, the description is a bit vague, not sure what you want to say
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
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.
You must first build.create() to create an alertdialog, and then you can use alertdialog.show() and alertdialog.dismiss()
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