android.widget.NumberPicker Java Examples

The following examples show how to use android.widget.NumberPicker. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RefreshDurationFragment.java    From wallpaperboard with Apache License 2.0 6 votes vote down vote up
private void setDividerColor (NumberPicker picker) {
    java.lang.reflect.Field[] pickerFields = NumberPicker.class.getDeclaredFields();
    for (java.lang.reflect.Field pf : pickerFields) {
        if (pf.getName().equals("mSelectionDivider")) {
            pf.setAccessible(true);
            try {
                int color = ColorHelper.getAttributeColor(getActivity(), R.attr.colorAccent);
                pf.set(picker, DrawableHelper.getTintedDrawable(
                        getActivity(), R.drawable.numberpicker_divider, color));
            } catch (Exception e) {
                LogUtil.e(Log.getStackTraceString(e));
            }
            break;
        }
    }
}
 
Example #2
Source File: SnoozeActivity.java    From NightWatch with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    alertStatus = (TextView) findViewById(R.id.alert_status);
    snoozeValue = (NumberPicker) findViewById(R.id.snooze);

    prefs =  PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    doMgdl = (prefs.getString("units", "mgdl").compareTo("mgdl") == 0);

    addListenerOnButton();
    if(BgGraphBuilder.isXLargeTablet(getApplicationContext())) {
        alertStatus.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
        buttonSnooze.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
    }

    displayStatus();
}
 
Example #3
Source File: MaterialNumberPicker.java    From MaterialNumberPicker with Apache License 2.0 6 votes vote down vote up
/**
 * Init number picker by disabling focusability of edit text embedded inside the number picker
 * We also override the edit text filter private attribute by using reflection as the formatter is still buggy while attempting to display the default value
 * This is still an open Google @see <a href="https://code.google.com/p/android/issues/detail?id=35482#c9">issue</a> from 2012
 */
private void initView() {
    setMinValue(MIN_VALUE);
    setMaxValue(MAX_VALUE);
    setValue(DEFAULT_VALUE);
    setBackgroundColor(BACKGROUND_COLOR);
    setSeparatorColor(SEPARATOR_COLOR);
    setTextColor(TEXT_COLOR);
    setTextSize(TEXT_SIZE);
    setWrapSelectorWheel(false);
    setFocusability(false);

    try {
        Field f = NumberPicker.class.getDeclaredField("mInputText");
        f.setAccessible(true);
        EditText inputText = (EditText)f.get(this);
        inputText.setFilters(new InputFilter[0]);
    } catch (NoSuchFieldException | IllegalAccessException | IllegalArgumentException e) {
        e.printStackTrace();
    }
}
 
Example #4
Source File: NumberPickerPreference.java    From a with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @return dialog view with picker inside
 */
@Override
protected View onCreateDialogView() {
    FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.gravity = Gravity.CENTER;

    numPicker = new NumberPicker(getContext());
    numPicker.setLayoutParams(layoutParams);
    numPicker.setMinValue(minValue);
    numPicker.setMaxValue(maxValue);

    FrameLayout dialogView = new FrameLayout(getContext());
    dialogView.addView(numPicker);

    return dialogView;
}
 
Example #5
Source File: TimeIntervalPreference.java    From chronosnap with MIT License 6 votes vote down vote up
/**
 * Perform initialization of the view items
 */
@Override
protected void onBindDialogView(View view) {
    super.onBindDialogView(view);

    // Obtain the current value
    long currentValue = Long.valueOf(getPersistedString(
            getContext().getString(R.string.pref_interval_default)));
    Interval interval = getInterval(currentValue);

    // Obtain references to the pickers and initialize them with the correct value
    mHourPicker = (NumberPicker) view.findViewById(R.id.hourPicker);
    mHourPicker.setMinValue(0);
    mHourPicker.setMaxValue(23);
    mHourPicker.setValue(interval.mHours);

    mMinutePicker = (NumberPicker) view.findViewById(R.id.minutePicker);
    mMinutePicker.setMinValue(0);
    mMinutePicker.setMaxValue(59);
    mMinutePicker.setValue(interval.mMinutes);

    mSecondPicker = (NumberPicker) view.findViewById(R.id.secondPicker);
    mSecondPicker.setMinValue(0);
    mSecondPicker.setMaxValue(59);
    mSecondPicker.setValue(interval.mSeconds);
}
 
Example #6
Source File: EditMovieFragment.java    From Mizuu with Apache License 2.0 6 votes vote down vote up
private void showRuntimeDialog(int initialValue) {
    final View numberPickerLayout = getActivity().getLayoutInflater().inflate(R.layout.number_picker_dialog, null, false);
    final NumberPicker numberPicker = (NumberPicker) numberPickerLayout.findViewById(R.id.number_picker);
    numberPicker.setMaxValue(600);
    numberPicker.setMinValue(0);
    numberPicker.setValue(initialValue);

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(R.string.set_runtime);
    builder.setView(numberPickerLayout);
    builder.setNeutralButton(R.string.set, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            // Update the runtime
            mMovie.setRuntime(numberPicker.getValue());

            // Update the UI with the new value
            setupValues(false);

            // Dismiss the dialog
            dialog.cancel();
        }
    });
    builder.show();
}
 
Example #7
Source File: TimezonePickerPopup.java    From arcusandroid with Apache License 2.0 6 votes vote down vote up
@Override public void doContentSection() {
    timezones = getTimezones();
    picker = (NumberPicker) contentView.findViewById(R.id.floating_day_number_picker);
    picker.setVisibility(View.GONE);
    picker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
    picker.setMinValue(0);

    String[] displayedValues = new String[timezones.size()];
    for (int i = 0; i < timezones.size(); i++) {
        displayedValues[i] = timezones.get(i).getName();
    }

    picker.setMaxValue(displayedValues.length - 1);
    picker.setDisplayedValues(displayedValues);
    picker.setValue(getIndexOfCurrentZoneOrDefault(0));
    picker.setVisibility(View.VISIBLE);

    Bundle args = getArguments();
    if (args == null) {
        forceNotification = false;
    } else {
        forceNotification = args.getBoolean(FORCE_NOTIFICATION, false);
    }
}
 
Example #8
Source File: FormatPickerDialog.java    From Android-Webcam with Apache License 2.0 6 votes vote down vote up
@Override
public void onStart() {
    super.onStart();
    setCancelable(false);

    numberPicker = (NumberPicker) getDialog().findViewById(R.id.number_picker);
    numberPicker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
    numberPicker.setDisplayedValues(values);
    numberPicker.setMinValue(getMinimumValue());
    numberPicker.setMaxValue(getMaximumValue());
    numberPicker.setValue(getInitialValue());
    numberPicker.setWrapSelectorWheel(false);
    numberPicker.setOnValueChangedListener(new OnValueChangeListener() {
        @Override public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
            currentIndex = newVal;
        }
    });
}
 
Example #9
Source File: NumberPickerPreference.java    From MaterialPreference with Apache License 2.0 6 votes vote down vote up
@SuppressLint("RestrictedApi")
public NumberPickerPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);

    mNumberPicker = new NumberPicker(context);

    TypedArray a;
    a = context.obtainStyledAttributes(attrs, R.styleable.NumberPickerPreference);
    mNumberPicker.setMinValue(a.getInt(R.styleable.NumberPickerPreference_min, 0));
    mNumberPicker.setMaxValue(a.getInt(R.styleable.NumberPickerPreference_max, 100));

    a = context.obtainStyledAttributes(attrs,
            R.styleable.Preference, defStyleAttr, defStyleRes);

    mSummary = TypedArrayUtils.getString(a, R.styleable.Preference_summary,
            R.styleable.Preference_android_summary);

    a.recycle();
}
 
Example #10
Source File: MaterialNumberPicker.java    From TLint with Apache License 2.0 6 votes vote down vote up
/**
 * Init number picker by disabling focusability of edit text embedded inside the number picker
 * We also override the edit text filter private attribute by using reflection as the formatter
 * is
 * still buggy while attempting to display the default value
 * This is still an open Google @see <a href="https://code.google.com/p/android/issues/detail?id=35482#c9">issue</a>
 * from 2012
 */
private void initView() {
    setMinValue(MIN_VALUE);
    setMaxValue(MAX_VALUE);
    setValue(DEFAULT_VALUE);
    setBackgroundColor(BACKGROUND_COLOR);
    setSeparatorColor(SEPARATOR_COLOR);
    setTextColor(TEXT_COLOR);
    setTextSize(TEXT_SIZE);
    setWrapSelectorWheel(false);
    setFocusability(false);

    try {
        Field f = NumberPicker.class.getDeclaredField("mInputText");
        f.setAccessible(true);
        EditText inputText = (EditText) f.get(this);
        inputText.setFilters(new InputFilter[0]);
    } catch (NoSuchFieldException | IllegalAccessException | IllegalArgumentException e) {
        e.printStackTrace();
    }
}
 
Example #11
Source File: MaterialNumberPicker.java    From TLint with Apache License 2.0 6 votes vote down vote up
/**
 * Uses reflection to access divider private attribute and override its color
 * Use Color.Transparent if you wish to hide them
 */
public void setSeparatorColor(int separatorColor) {
    mSeparatorColor = separatorColor;

    Field[] pickerFields = NumberPicker.class.getDeclaredFields();
    for (Field pf : pickerFields) {
        if (pf.getName().equals("mSelectionDivider")) {
            pf.setAccessible(true);
            try {
                pf.set(this, new ColorDrawable(separatorColor));
            } catch (IllegalAccessException | IllegalArgumentException e) {
                e.printStackTrace();
            }
            break;
        }
    }
}
 
Example #12
Source File: SnoozeActivity.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
static void SetSnoozePickerValues(NumberPicker picker, boolean above, int default_snooze) {
    String[] values=new String[snoozeValues.length];
    for(int i=0;i<values.length;i++){
        values[i]=getNameFromTime(snoozeValues[i]);
    }

    picker.setMaxValue(values.length -1);
    picker.setMinValue(0);
    picker.setDisplayedValues(values);
    picker.setWrapSelectorWheel(false);
    if(default_snooze != 0) {
        picker.setValue(getSnoozeLocatoin(default_snooze));
    } else {
        picker.setValue(getSnoozeLocatoin(getDefaultSnooze(above)));
    }
}
 
Example #13
Source File: CustomTileDimensions.java    From material-calendarview with MIT License 6 votes vote down vote up
@OnClick(R.id.custom_tile_width_size)
public void onWidthClick() {
  final NumberPicker view = new NumberPicker(this);
  view.setMinValue(24);
  view.setMaxValue(64);
  view.setWrapSelectorWheel(false);
  view.setValue(currentTileWidth);
  new AlertDialog.Builder(this)
      .setView(view)
      .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(@NonNull DialogInterface dialog, int which) {
          currentTileWidth = view.getValue();
          widget.setTileWidthDp(currentTileWidth);
        }
      })
      .show();
}
 
Example #14
Source File: SnoozeActivity.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
static void SetSnoozePickerValues(NumberPicker picker, boolean above, int default_snooze) {
    String[] values=new String[snoozeValues.length];
    for(int i=0;i<values.length;i++){
        values[i]=getNameFromTime(snoozeValues[i]);
    }

    picker.setMaxValue(values.length -1);
    picker.setMinValue(0);
    picker.setDisplayedValues(values);
    picker.setWrapSelectorWheel(false);
    if(default_snooze != 0) {
        picker.setValue(getSnoozeLocatoin(default_snooze));
    } else {
        picker.setValue(getSnoozeLocatoin(getDefaultSnooze(above)));
    }
}
 
Example #15
Source File: NumberPickerPreference.java    From HaoReader with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @return dialog view with picker inside
 */
@Override
protected View onCreateDialogView() {
    FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.gravity = Gravity.CENTER;

    numPicker = new NumberPicker(getContext());
    numPicker.setLayoutParams(layoutParams);
    numPicker.setMinValue(minValue);
    numPicker.setMaxValue(maxValue);

    FrameLayout dialogView = new FrameLayout(getContext());
    dialogView.addView(numPicker);

    return dialogView;
}
 
Example #16
Source File: DynamicSettersActivity.java    From material-hijri-calendarview with Apache License 2.0 6 votes vote down vote up
@OnClick(R.id.button_set_tile_size)
void onTileSizeClicked() {
    final NumberPicker view = new NumberPicker(this);
    view.setMinValue(24);
    view.setMaxValue(64);
    view.setWrapSelectorWheel(false);
    view.setValue(currentTileSize);
    new AlertDialog.Builder(this)
            .setView(view)
            .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(@NonNull DialogInterface dialog, int which) {
                    currentTileSize = view.getValue();
                    widget.setTileSizeDp(currentTileSize);
                }
            })
            .show();
}
 
Example #17
Source File: CustomTileDimensions.java    From material-calendarview with MIT License 6 votes vote down vote up
@OnClick(R.id.custom_tile_height_size)
public void onHeightClick() {
  final NumberPicker view = new NumberPicker(this);
  view.setMinValue(24);
  view.setMaxValue(64);
  view.setWrapSelectorWheel(false);
  view.setValue(currentTileHeight);
  new AlertDialog.Builder(this)
      .setView(view)
      .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(@NonNull DialogInterface dialog, int which) {
          currentTileHeight = view.getValue();
          widget.setTileHeightDp(currentTileHeight);
        }
      })
      .show();
}
 
Example #18
Source File: SnoozeActivity.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (Home.get_holo()) { setTheme(R.style.OldAppThemeNoTitleBar); }
    JoH.fixActionBar(this);
    setContentView(R.layout.activity_snooze);
    alertStatus = (TextView) findViewById(R.id.alert_status);
    snoozeValue = (NumberPicker) findViewById(R.id.snooze);

    prefs =  PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    doMgdl = (prefs.getString("units", "mgdl").compareTo("mgdl") == 0);

    addListenerOnButton();
    if(BgGraphBuilder.isXLargeTablet(getApplicationContext())) {
        alertStatus.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
        buttonSnooze.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
    }
    displayStatus();
}
 
Example #19
Source File: DayFragment.java    From SlideDayTimePicker with Apache License 2.0 6 votes vote down vote up
/**
 * Enable or disable NumberPicker editing. We use this to turn
 * off editing and this has the effect of removing the blinking
 * cursor that is shown by default.
 */
private void enableNumberPickerEditing(NumberPicker numberPicker, boolean enable)
{
    int childCount = numberPicker.getChildCount();

    for (int i = 0; i < childCount; i++)
    {
        View childView = numberPicker.getChildAt(i);

        if (childView instanceof EditText)
        {
            EditText editText = (EditText) childView;
            editText.setFocusable(enable);
            return;
        }
    }
}
 
Example #20
Source File: SnoozeActivity.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
static void SetSnoozePickerValues(NumberPicker picker, boolean above, int default_snooze) {
    String[] values=new String[snoozeValues.length];
    for(int i=0;i<values.length;i++){
        values[i]=getNameFromTime(snoozeValues[i]);
    }

    picker.setMaxValue(values.length -1);
    picker.setMinValue(0);
    picker.setDisplayedValues(values);
    picker.setWrapSelectorWheel(false);
    if(default_snooze != 0) {
        picker.setValue(getSnoozeLocatoin(default_snooze));
    } else {
        picker.setValue(getSnoozeLocatoin(getDefaultSnooze(above)));
    }
}
 
Example #21
Source File: SnoozeActivity.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //KS if (Home.get_holo()) { setTheme(R.style.OldAppTheme); }
    setContentView(R.layout.activity_snooze);
    alertStatus = (TextView) findViewById(R.id.alert_status);
    snoozeValue = (NumberPicker) findViewById(R.id.snooze);

    prefs =  PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    doMgdl = (prefs.getString("units", "mgdl").compareTo("mgdl") == 0);

    addListenerOnButton();
    if(BgGraphBuilder.isXLargeTablet(getApplicationContext())) {
        alertStatus.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
        buttonSnooze.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
    }
    displayStatus();
}
 
Example #22
Source File: SnoozeActivity.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
static void SetSnoozePickerValues(NumberPicker picker, boolean above, int default_snooze) {
    String[] values=new String[snoozeValues.length];
    for(int i=0;i<values.length;i++){
        values[i]=getNameFromTime(snoozeValues[i]);
    }

    picker.setMaxValue(values.length -1);
    picker.setMinValue(0);
    picker.setDisplayedValues(values);
    picker.setWrapSelectorWheel(false);
    if(default_snooze != 0) {
        picker.setValue(getSnoozeLocatoin(default_snooze));
    } else {
        picker.setValue(getSnoozeLocatoin(getDefaultSnooze(above)));
    }
}
 
Example #23
Source File: SnoozeActivity.java    From NightWatch with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    alertStatus = (TextView) findViewById(R.id.alert_status);
    snoozeValue = (NumberPicker) findViewById(R.id.snooze);

    prefs =  PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    doMgdl = (prefs.getString("units", "mgdl").compareTo("mgdl") == 0);

    addListenerOnButton();
    if(BgGraphBuilder.isXLargeTablet(getApplicationContext())) {
        alertStatus.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
        buttonSnooze.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
    }

    displayStatus();
}
 
Example #24
Source File: AlarmOffsetDialog.java    From SuntimesWidget with GNU General Public License v3.0 6 votes vote down vote up
protected void initViews( final Context context, View dialogContent )
{
    pickerDirection = (NumberPicker) dialogContent.findViewById(R.id.alarmOption_offset_direction);
    pickerDirection.setMinValue(0);
    pickerDirection.setMaxValue(1);
    pickerDirection.setDisplayedValues( new String[] {context.getString(R.string.offset_button_before), context.getString(R.string.offset_button_after)} );
    pickerDirection.setOnValueChangedListener(onOffsetChanged);

    pickerOffsetMinutes = (NumberPicker) dialogContent.findViewById(R.id.alarmOption_offset_minute);
    pickerOffsetMinutes.setMinValue(0);
    pickerOffsetMinutes.setMaxValue(minuteStrings.length-1);
    pickerOffsetMinutes.setDisplayedValues(minuteStrings);
    pickerOffsetMinutes.setOnValueChangedListener(onOffsetChanged);

    pickerOffsetHours = (NumberPicker) dialogContent.findViewById(R.id.alarmOption_offset_hour);
    pickerOffsetHours.setMinValue(0);
    pickerOffsetHours.setMaxValue(hourStrings.length-1);
    pickerOffsetHours.setDisplayedValues(hourStrings);
    pickerOffsetHours.setOnValueChangedListener(onOffsetChanged);

    pickerOffsetDays = (NumberPicker) dialogContent.findViewById(R.id.alarmOption_offset_day);
    pickerOffsetDays.setMinValue(0);
    pickerOffsetDays.setMaxValue(dayStrings.length-1);
    pickerOffsetDays.setDisplayedValues(dayStrings);
    pickerOffsetDays.setOnValueChangedListener(onOffsetChanged);
}
 
Example #25
Source File: Dialogs.java    From Aegis with GNU General Public License v3.0 6 votes vote down vote up
public static void showBackupVersionsPickerDialog(Activity activity, NumberInputListener listener) {
    final int max = 30;
    String[] numbers = new String[max / 5];
    for (int i = 0; i < numbers.length; i++) {
        numbers[i] = Integer.toString(i * 5 + 5);
    }

    View view = activity.getLayoutInflater().inflate(R.layout.dialog_number_picker, null);
    NumberPicker numberPicker = view.findViewById(R.id.numberPicker);
    numberPicker.setDisplayedValues(numbers);
    numberPicker.setMaxValue(numbers.length - 1);
    numberPicker.setMinValue(0);
    numberPicker.setValue(new Preferences(activity.getApplicationContext()).getBackupsVersionCount() / 5 - 1);
    numberPicker.setWrapSelectorWheel(false);

    AlertDialog dialog = new AlertDialog.Builder(activity)
            .setTitle(R.string.set_number)
            .setView(view)
            .setPositiveButton(android.R.string.ok, (dialog1, which) ->
                    listener.onNumberInputResult(numberPicker.getValue()))
            .create();

    showSecureDialog(dialog);
}
 
Example #26
Source File: SnoozeActivity.java    From NightWatch with GNU General Public License v3.0 6 votes vote down vote up
static void SetSnoozePickerValues(NumberPicker picker, boolean above, int default_snooze) {
    String[] values=new String[snoozeValues.length];
    for(int i=0;i<values.length;i++){
        values[i]=getNameFromTime(snoozeValues[i]);
    }

    picker.setMaxValue(values.length -1);
    picker.setMinValue(0);
    picker.setDisplayedValues(values);
    picker.setWrapSelectorWheel(false);
    if(default_snooze != 0) {
        picker.setValue(getSnoozeLocatoin(default_snooze));
    } else {
        picker.setValue(getSnoozeLocatoin(getDefaultSnooze(above)));
    }
}
 
Example #27
Source File: VNTNumberPickerPreference.java    From VNTNumberPickerPreference with Apache License 2.0 6 votes vote down vote up
@Override
protected void onPrepareDialogBuilder(final Builder builder) {
    super.onPrepareDialogBuilder(builder);

    numberPicker = new NumberPicker(this.getContext());
    numberPicker.setMinValue(minValue);
    numberPicker.setMaxValue(maxValue);
    numberPicker.setValue(selectedValue);
    numberPicker.setWrapSelectorWheel(wrapSelectorWheel);
    numberPicker.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    final LinearLayout linearLayout = new LinearLayout(this.getContext());
    linearLayout.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    linearLayout.setGravity(Gravity.CENTER);
    linearLayout.addView(numberPicker);

    builder.setView(linearLayout);
}
 
Example #28
Source File: NumberPickerPreference.java    From MyBookshelf with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @return dialog view with picker inside
 */
@Override
protected View onCreateDialogView() {
    FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.gravity = Gravity.CENTER;

    numPicker = new NumberPicker(getContext());
    numPicker.setLayoutParams(layoutParams);
    numPicker.setMinValue(minValue);
    numPicker.setMaxValue(maxValue);

    FrameLayout dialogView = new FrameLayout(getContext());
    dialogView.addView(numPicker);

    return dialogView;
}
 
Example #29
Source File: NumberPickerPreferenceFragment.java    From libcommon with Apache License 2.0 5 votes vote down vote up
@Override
public void onValueChange(final NumberPicker picker, final int oldVal, final int newVal) {
	if (DEBUG) Log.v(TAG, "onValueChange:newVal=" + newVal);
	if (oldVal != newVal) {
		changed = true;
	}
	mValue = newVal;
}
 
Example #30
Source File: NumberPickerPreference.java    From comfortreader with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected View onCreateDialogView() {
    FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.gravity = Gravity.CENTER;

    picker = new NumberPicker(getContext());
    picker.setLayoutParams(layoutParams);

    FrameLayout dialogView = new FrameLayout(getContext());
    dialogView.addView(picker);

    return dialogView;
}