Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DialogFragment Close Event

I need to handle the end of a DialogFragment (after a call to .dismiss) - for example, I would show a toast inside the activity that "contains" the fragment after dismiss.

How do I handle the event?

like image 808
giozh Avatar asked Mar 01 '13 17:03

giozh


People also ask

Is DialogFragment deprecated?

This method is deprecated. androidx.

How do I close DialogFragment on Android?

tl;dr: The correct way to close a DialogFragment is to use dismiss() directly on the DialogFragment. Control of the dialog (deciding when to show, hide, dismiss it) should be done through the API here, not with direct calls on the dialog. Dismiss the fragment and its dialog.

What is the difference between dialog & DialogFragment?

Dialog: A dialog is a small window that prompts the user to make a decision or enter additional information. DialogFragment: A DialogFragment is a special fragment subclass that is designed for creating and hosting dialogs.

What is a DialogFragment?

Android DialogFragments. DialogFragment is a utility class which extends the Fragment class. It is a part of the v4 support library and is used to display an overlay modal window within an activity that floats on top of the rest of the content. Essentially a DialogFragment displays a Dialog but inside a Fragment.


1 Answers

Override onDismiss() in your DialogFragment, or use setOnDismissListener() in the code block where you are building the fragment.

like image 111
Austyn Mahoney Avatar answered Sep 27 '22 21:09

Austyn Mahoney