1

I have a fragment that creates a dialogFragment with no buttons. I want the fragment to run a method after the dialog has been dismissed by either the back button or by clicking outside of the dialog. I have tried looking for an answer, but all I have found is the possibility of setting up positive/negative/neutral buttons. I wouldn't want buttons if possible. How could this be accomplished?

Note: I have tried onResume(), but that doesn't get called after the dialog is dismissed.

4

2 回答 2

3

覆盖onDismissDialogFragment 中的方法,该方法在对话框被关闭时调用

于 2013-07-17T19:20:20.593 回答
3

方法 setOnDismissListener 和 setOnCancelListener 不可用?

我认为你可以这样做:

dialog.setOnDismissListener(new OnDismissListener() {

            @Override
            public void onDismiss(DialogInterface dialog) {
                // TODO Auto-generated method stub

            }
        });

或者:

dialog.setCancelable(true);
        dialog.setOnCancelListener(new OnCancelListener() {

            @Override
            public void onCancel(DialogInterface dialog) {
                //YOUR CODE
            }
        });
于 2013-07-17T19:22:51.940 回答