amitairos amitairos - 1 month ago 38
Android Question

Xamarin TimePicker Fragment Dialog

I'm working on a Xamarin Android app in C#, and I'm trying to implement a TimePicker dialog, in which the user chooses a given time, and they will be notified every day (or the days in the week that he chooses).

I understand There is a TimePickerDialog Control that was deprecated, and that we need to use now a Fragment Dialog. If anyone can help me, I'd very much appreciate it.

Thanks!

Answer

Here is sample code from project:

class TimePickerFragment : DialogFragment
{
    public override Dialog OnCreateDialog(Bundle savedInstanceState)
    {
        return new TimePickerDialog(Activity, (sender, args) =>
        {
            //args contains new time
        }, DateTime.Now.Hour, DateTime.Now.Minute, true);
    }
}
Comments