Beispiel #1
0
        public void Init(Drawable imageSource = null, string text = "", string scope = "")
        {
            Inflate(Context, Resource.Layout.WheelPicker, this);

            var title = (Button)FindViewById(Resource.Id.alertButton);

            title.Text = "PICKER";

            CancelButton   = (Button)FindViewById(Resource.Id.cancelButton);
            ValidateButton = (Button)FindViewById(Resource.Id.validateButton);
            Menu           = (LinearLayout)FindViewById(Resource.Id.menu);

            CancelButton.Text   = "CANCEL";
            ValidateButton.Text = "VALIDATE";

            CancelButton.SetOnClickListener(this);
            ValidateButton.SetOnClickListener(this);

            // set current time
            Calendar calendar = Calendar.GetInstance(Locale.Us);

            _ampm = (AbstractWheel)FindViewById(Resource.Id.ampmSpinner);

            if (IsFr)
            {
                _ampm.Visibility = ViewStates.Gone;
            }
            else
            {
                _ampm.Visibility = ViewStates.Visible;

                var am = new JavaObjectWrapper <string> {
                    Obj = "AM"
                };
                var pm = new JavaObjectWrapper <string> {
                    Obj = "PM"
                };

                var ampmAdapter = new ArrayWheelAdapter(Context, new Java.Lang.Object[] { am.Obj, pm.Obj })
                {
                    ItemResource     = Resource.Layout.WheelTextCentered,
                    ItemTextResource = Resource.Id.text
                };

                _ampm.ViewAdapter        = ampmAdapter;
                _ampm.ScrollingFinished += OnScrollingFinished();
            }

            _daySpinner = (WheelVerticalView)FindViewById(Resource.Id.daySpinner);
            var dayAdapter = new DayArrayAdapter(Context, calendar);

            _daySpinner.ViewAdapter = dayAdapter;
            _daySpinner.SetCurrentItem(dayAdapter.GetToday(), true);
            _daySpinner.SetActiveCoeff(0);
            _daySpinner.SetPassiveCoeff(.5f);
            _daySpinner.ScrollingFinished += OnScrollingFinished();

            _hoursSpinner             = (AbstractWheelView)FindViewById(Resource.Id.hourSpinner);
            _hoursSpinner.ViewAdapter = new NumericWheelAdapter(Context, _hourStartIndex, _hourLastIndex, "%02d");
            ((NumericWheelAdapter)_hoursSpinner.ViewAdapter).ItemResource     = Resource.Layout.time_picker_custom_day;
            ((NumericWheelAdapter)_hoursSpinner.ViewAdapter).ItemTextResource = Resource.Id.time2_monthday;
            _hoursSpinner.Cyclic = true;
            _hoursSpinner.SetActiveCoeff(0);
            _hoursSpinner.SetPassiveCoeff(.5f);
            _hoursSpinner.ScrollingFinished += OnScrollingFinished();

            _minSpinner             = (AbstractWheelView)FindViewById(Resource.Id.minSpinner);
            _minSpinner.ViewAdapter = new IntervalMinuteArrayAdapter(Context, 15, 3);
            _minSpinner.Cyclic      = true;
            _minSpinner.SetActiveCoeff(0);
            _minSpinner.SetPassiveCoeff(.5f);
            _minSpinner.ScrollingFinished += OnScrollingFinished();

            SetDefault();
            Hide();
        }