Book Image

Xamarin Mobile Application Development for Android, Second Edition

Book Image

Xamarin Mobile Application Development for Android, Second Edition

Overview of this book

Table of Contents (18 chapters)
Xamarin Mobile Application Development for Android Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Working with DialogFragment


In this chapter, we already covered how to use the fragment and ListFragment to optimize layout for Android tablets. Let's now discuss another specialized fragment subclass, DialogFragment. The current implementation of the POIApp uses AlertDialog to display the confirmation dialog to a user before deleting the POI. In this section, we will replace the AlertDialog implementation with DialogFragment.

DialogFragment is used to display a fragment as a floating dialog window that pops up on top of the current window. DialogFragment is the subclass of fragment and was introduced in Android 3.0 API level 11. Google recommends that you use DialogFragment for implementing the dialog because of the following reasons:

  • Like normal fragments, DialogFragment manages its own life cycle. Events such as the user pressing the device's Back button or rotating the screen are handled in DialogFragment.

  • A DialogFragment UI can be reused and embedded inside another activity. For example...