Exemplo n.º 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();
            }
        }
Exemplo n.º 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();
        }