// Factory method used to create a new TimePickerFragment: public static TimePickerFragment NewInstance(Action <DateTime> onTimeSelected) { // Instantiate a new TimePickerFragment: TimePickerFragment frag = new TimePickerFragment(); // Set its event handler to the passed-in delegate: frag.timeSelectedHandler = onTimeSelected; // Return the new TimePickerFragment: return(frag); }
void TimeSelectOnClick(object sender, EventArgs eventArgs) { // Instantiate a TimePickerFragment (defined below) string schudleName = ((TextView)sender).TransitionName; TimePickerFragment frag = TimePickerFragment.NewInstance( // Create and pass in a delegate that updates the Activity time display // with the passed-in time value: delegate(DateTime time) { ((TextView)sender).Text = "Time: " + time.ToShortTimeString(); }); // Launch the TimePicker dialog fragment (defined below): frag.Show(FragmentManager, TimePickerFragment.TAG); }