示例#1
0
        void CreateDialog()
        {
            if (_dialog == null)
            {
                bool is24HourFormat = DateFormat.Is24HourFormat(_context);
                _dialog = new TimePickerDialog(_context, TimeSelected, _TimePickerCell.Time.Hours, _TimePickerCell.Time.Minutes, is24HourFormat);

                var title = new TextView(_context);

                if (!string.IsNullOrEmpty(_title))
                {
                    title.Gravity = Android.Views.GravityFlags.Center;
                    title.SetPadding(10, 10, 10, 10);
                    title.Text = _title;
                    _dialog.SetCustomTitle(title);
                }

                _dialog.SetCanceledOnTouchOutside(true);

                _dialog.DismissEvent += (ss, ee) =>
                {
                    title.Dispose();
                    _dialog.Dispose();
                    _dialog = null;
                };

                _dialog.Show();
            }
        }
示例#2
0
        private void CreateDialog()
        {
            if (_Dialog != null)
            {
                return;
            }
            _Dialog = new TimePickerDialog(AndroidContext,
                                           TimeSelected,
                                           _TimePickerCell.Time.Hours,
                                           _TimePickerCell.Time.Minutes,
                                           DateFormat.Is24HourFormat(AndroidContext)
                                           );

            var title = new TextView(AndroidContext)
            {
                Gravity = Android.Views.GravityFlags.Center,
                Text    = string.IsNullOrEmpty(_PopupTitle) ? "Select Time" : _PopupTitle,
            };

            title.SetBackgroundColor(_TimePickerCell.Prompt.BackgroundColor.ToAndroid());
            title.SetTextColor(_TimePickerCell.Prompt.TitleColor.ToAndroid());
            title.SetPadding(10, 10, 10, 10);

            _Dialog.SetCustomTitle(title);
            _Dialog.SetCanceledOnTouchOutside(true);

            _Dialog.DismissEvent += (sender, e) =>
            {
                title.Dispose();
                _Dialog.Dispose();
                _Dialog = null;
            };

            _Dialog.Show();
        }
        public void OnClick(global::Android.Views.View v)
        {
            var dialog = new TimePickerDialog(Context, new EventHandler <TimePickerDialog.TimeSetEventArgs>(OnTimeSet), _control.Time.Hours, _control.Time.Minutes, _control.Is24Hour);

            dialog.SetCustomTitle(new TextView(Context)
            {
                Visibility = ViewStates.Gone
            });
            dialog.Show();
        }