First, the content is set to the Main.axml layout and then the TextView and Button are captured with FindViewById(int). Then the button's Click event is attached to, so that when clicked, it will call ShowDialog(int), passing the unique integer ID for the time picker dialog. Using ShowDialog(int) allows the Activity to manage the life-cycle of the dialog and will call the OnCreateDialog(int) callback method to request the Dialog that should be displayed (which you'll define later). After the on-click listener is set, we set the current hour and minute. Finally, the private UpdateDisplay() method is called in order to fill the TextView with the current time.