search

Home  >  Q&A  >  body text

java - 使用AlertDialog.Builder点击确定需要进行一个网络操作,结果报错

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

reply all(7)I'll reply

  • 阿神

    阿神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.

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-18 09:23:45

    I suggest you post the code, it’s hard to understand!

    reply
    0
  • 巴扎黑

    巴扎黑2017-04-18 09:23:45

    Same as above, the description is a bit vague, not sure what you want to say

    reply
    0
  • 高洛峰

    高洛峰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

    reply
    0
  • ringa_lee

    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.

    reply
    0
  • 怪我咯

    怪我咯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()

    reply
    0
  • 黄舟

    黄舟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

    reply
    0
  • Cancelreply