Create your account

Already have an account? Login here

Note: By joining, you will receive periodic emails from Coursetro. You can unsubscribe from these emails.

Create account

54. Introduction to Dialog Fragments

Design + Code an Android App from Scratch

Woah, wait a second..

Scrounge up some loose change to become a pro member, or login to your account to view this lesson.

Alright, join now. Or login to your account if you're already a pro member.

This video talks about a fragment that displays a dialog window, floating on top of its activity's window called a DialogFragment in Android. This fragment contains a Dialog object, which it displays as appropriate based on the fragment's state. 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. You can implement one either using the Fragment approach in which case you use the onCreateView method or the Dialog approach in which case you use the onCreateDialog approach. Create an XML layout of the Dialog that you want to display. Create a class that extends from DialogFragment. Override the onCreateView method or the onCreateDialog method depending on your chosen approach. Construct the object of a DialogFragment inside your activity and simply call the show method to display the Dialog or dismiss method to destroy the Dialog.

Course Cirriculum