Reputation: 10078
I have an activity
public class ShowFileActivity extends FragmentActivity
and when occours some event, this class call a DialogFragment
public class ConfirmDialog extends DialogFragment
that is a simple confirm dialog (with "dismiss" and "ok" button). If user press dismiss button, i call
dismiss()
and come back to ShowFileActivity. Else, if user press ok, after made some operations, after call dismiss on dialog, i would go back to parent activity of ShowFileActivity. There's a way to do it? Does DialogFragment launch any event to his parent view?
Upvotes: 6
Views: 5340
Reputation: 6862
What you can do is to call a method of the containing activity from inside the fragment. As per any other fragment, you can call getActivity() which returns the containing activity.
@Override
public void onDismiss(DialogInterface dialog) {
ShowFileActivity parent = (ShowFileActivity) getActivity();
parent.doWhateverYouWantWhenDialogDismissed();
}
Another (more fancy) approach would be to use an event bus such as otto or greenrobot.
Upvotes: 8