AlertDialog via Fragment: Android Programming

Please login in order to report media.

  • Uploaded 8 months ago in the category How to programming

    Create an AlertDialog using AppCompatDialogFragment.

    Interact with the parent activity by setting text in a TextView, and by closing it with .finish().
    Support videos via Patreon:

    - Setup MainActivity with a TextView to edit, and a button to trigger the dialog box.
    - Create a layout XML file for the dialog's appearance
    - Create a Java class inheriting from AppCompatDialogFragment to build the AlertDialog
    - Show the AlertDialog from main using a fragment manager.
    - Add a cancel button
    - Call .finish() on the parent activity to close it.

  • alertdialogfragment:androidprogramming