@Override protected void onBindDialogView(View view) { super.onBindDialogView(view); picker = (CustomNumberPicker) view.findViewById(R.id.numpicker_pref); picker.setMaxValue(getNumberPickerPreference().maxValue); picker.setMinValue(getNumberPickerPreference().minValue); picker.setValue(currentValue); }
/** * Initializes the color picker dialog components. * * <p>Runs when the dialog opens.</p> * * @param view The color picker dialog layout. */ @Override protected void onBindDialogView(final View view) { super.onBindDialogView(view); final ColorPicker colorPicker = view.findViewById(R.id.colorPicker); final ValueBar valueBar = view.findViewById(R.id.colorPickerValueBar); final SaturationBar saturationBar = view.findViewById(R.id.colorPickerSaturationBar); final int persistedColor = getColorPickerPreference().getPersistedColor(); colorPicker.setOnColorChangedListener(this); colorPicker.addValueBar(valueBar); colorPicker.addSaturationBar(saturationBar); colorPicker.setColor(persistedColor); colorPicker.setOldCenterColor(persistedColor); }
/** * {@inheritDoc} */ @Override protected void onBindDialogView(View view) { super.onBindDialogView(view); mTimePicker = (TimePicker) view.findViewById(R.id.edit); // Exception: There is no TimePicker with the id 'edit' in the dialog. if (mTimePicker == null) { throw new IllegalStateException("Dialog view must contain a TimePicker with id 'edit'"); } // Get the time from the related Preference Integer minutesAfterMidnight = null; DialogPreference preference = getPreference(); if (preference instanceof TimePreference) { minutesAfterMidnight = ((TimePreference) preference).getTime(); } // Set the time to the TimePicker if (minutesAfterMidnight != null) { int hours = minutesAfterMidnight / 60; int minutes = minutesAfterMidnight % 60; boolean is24hour = DateFormat.is24HourFormat(getContext()); mTimePicker.setIs24HourView(is24hour); mTimePicker.setCurrentHour(hours); mTimePicker.setCurrentMinute(minutes); } }