java - 使用AlertDialog.Builder点击确定需要进行一个网络操作,结果报错
大家讲道理
大家讲道理 2017-04-18 09:21:45
0
7
803

使用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方法,并且点击效果本身就是取消了窗口的显示,,,,这个要怎么做?
大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(7)
阿神

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template