Android Dialog(1) – 2 Supplement

This article is a supplement of  Android Dialog (1).

In a place that explains how to add buttons on a dialog, I have introduced the only example of using the DialogFragment. Therefore, I will introduce the following example using the Activity.

If you use the DialogFragment, you place the listener and onCreateDialog method in it. On the other hand, if you do not use DialogFragment, you may place both in the Activity.

getActivity() is not a method of Activity. Therefore, I replaced it to this (because of the reference to the outer class from an anonymous class, MainActivity.this).

[Related Articles]
Android Dialog (1)
Android Dialog(2) -Custom Dialog-

Your email address will not be published.