Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

fragments in android

I created a class which is a extends dialog fragment. which is

public class AlertDialogFragment extends DialogFragment {
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setTitle("Oops sorry!").setMessage("There was an error. Please try again").setPositiveButton("OK",null);
        AlertDialog dialog = builder.create();
        return dialog;
    }

}

The main activity uses the fragmet in the following code.

private void alertUser() {
        AlertDialogFragment dialog = new AlertDialogFragment();
        dialog.show(getFragmentManager(),"Error_dialog");

    }

How does the type of dialog in main activity match with the type of dialog that is being returned from the AlertDialogFragment??

How does getFragmentManager() work? What does it return??