public static TimePickerDialog ShowTimePickerDialog(Context ctx, int textView) { try { var listener = new OnTimeSetListener(textView); var timePicker = new TimePickerDialog(ctx, listener, DateTime.Now.Hour, 0, false); timePicker.SetCancelable(false); timePicker.Show(); } catch (Exception ex) { ShowDialog(ctx, "An error occured while showing Time Picker\n\n Error Details:\n" + ex, "Exception"); } return(null); }
/// <summary> /// ShowMessage /// </summary> /// <returns></returns> public async Task <DateTimeOffset> ShowTimeDialog(string title, HourType type = HourType.TwelveHour) { var tcs = new TaskCompletionSource <DateTimeOffset>(); var timeDialog = new TimePickerDialog(CrossCurrentActivity.Current.Activity, Resource.Style.AppCompatDialogStyle, (sender, args) => { if (args == null) { tcs.TrySetResult(DateTime.Now); return; } var time = DateTime.Today.Add(new TimeSpan(args.HourOfDay, args.Minute, 0)); tcs.TrySetResult(time); }, DateTime.Now.Hour, DateTime.Now.Minute, type == HourType.TwentyFourHour); timeDialog.SetTitle(title); timeDialog.SetCancelable(true); timeDialog.Show(); return(await tcs.Task); }