How to know if a dialog is dismissed in Android?

后端 未结 4 1642
面向向阳花
面向向阳花 2020-12-29 19:43

If the dialog is dismissed,I want to do something for my background.So I want to know if the dialog is dismissed

4条回答
  •  时光说笑
    2020-12-29 20:38

    You can use an onDismissListener

    http://developer.android.com/reference/android/content/DialogInterface.OnDismissListener.html

    public Dialog createDialog() {
        Dialog d = new Dialog(this);
        d.setOnDismissListener(new OnDismissListener() {
            @Override
            public void onDismiss(final DialogInterface arg0) {
                // do something
            }
        });
        return d;
    }
    

    If you are using a DialogFragment just override onDismiss()

    http://developer.android.com/reference/android/app/DialogFragment.html#onDismiss(android.content.DialogInterface)

提交回复
热议问题