Created
May 27, 2017 12:35
-
-
Save dsibinski/6bddb5f760a83b1d190d7d20362f1546 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DatePickerFragment : DialogFragment, DatePickerDialog.IOnDateSetListener | |
{ | |
public static readonly string TAG = "X:" + typeof(DatePickerFragment).Name.ToUpper(); | |
Action<DateTime> _dateSelectedHandler = delegate { }; | |
public DatePickerFragment(Action<DateTime> onDateSelected) | |
{ | |
_dateSelectedHandler = onDateSelected; | |
} | |
public override Dialog OnCreateDialog(Bundle savedInstanceState) | |
{ | |
DateTime now = DateTime.Now; | |
return new DatePickerDialog(Activity, | |
this, | |
now.Year, | |
now.Month, | |
now.Day); | |
} | |
public void OnDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) | |
{ | |
DateTime selectedDate = new DateTime(year, monthOfYear + 1, dayOfMonth); | |
_dateSelectedHandler(selectedDate); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment