Java Code Examples for android.widget.NumberPicker#setMinValue()

The following examples show how to use android.widget.NumberPicker#setMinValue() . 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: 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 2
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 3
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 4
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 5
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 6
Source File: CustomTileDimensions.java    From calendarview2 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 7
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 8
Source File: SilenterPrompt.java    From prayer-times-android with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle bdl) {
    super.onCreate(bdl);
    widgets = getSharedPreferences("widgets", 0);

    setContentView(R.layout.vakit_silenterprompt);

    final NumberPicker np = findViewById(R.id.numberPicker);
    np.setMinValue(1);
    np.setMaxValue(300);
    np.setValue(widgets.getInt("silenterWidget", 15));

    findViewById(R.id.cancel).setOnClickListener(view -> finish());

    findViewById(R.id.ok).setOnClickListener(v -> {
        widgets.edit().putInt("silenterWidget", np.getValue()).apply();
        if (PermissionUtils.get(this).pNotPolicy)
            SilenterReceiver.silent(v.getContext(), np.getValue());
        else
            PermissionUtils.get(this).needNotificationPolicy(this);
        finish();
    });

}
 
Example 9
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 10
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 11
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 12
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 13
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 14
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 15
Source File: EditTvShowFragment.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
            mShow.setRuntime(numberPicker.getValue());

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

            // Dismiss the dialog
            dialog.cancel();
        }
    });
    builder.show();
}
 
Example 16
Source File: EditTvShowFragment.java    From Mizuu with Apache License 2.0 5 votes vote down vote up
private void showRatingDialog(double 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(100);
    numberPicker.setMinValue(0);
    numberPicker.setValue((int) (initialValue * 10));
    final TextView numberPickerText = (TextView) numberPickerLayout.findViewById(R.id.number_picker_text);
    numberPickerText.setText("%");

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

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

            // Dismiss the dialog
            dialog.cancel();
        }
    });
    builder.show();
}
 
Example 17
Source File: DynamicSettersActivity.java    From calendarview2 with MIT License 5 votes vote down vote up
@OnClick(R.id.button_set_width_height)
void onTileWidthHeightClicked() {
    final LinearLayout layout = new LinearLayout(this);
    layout.setOrientation(LinearLayout.HORIZONTAL);
    final NumberPicker pickerWidth = new NumberPicker(this);
    pickerWidth.setMinValue(24);
    pickerWidth.setMaxValue(64);
    pickerWidth.setWrapSelectorWheel(false);
    pickerWidth.setValue(currentTileWidth);
    final NumberPicker pickerHeight = new NumberPicker(this);
    pickerHeight.setMinValue(24);
    pickerHeight.setMaxValue(64);
    pickerHeight.setWrapSelectorWheel(false);
    pickerHeight.setValue(currentTileHeight);
    layout.addView(pickerWidth);
    layout.addView(pickerHeight);
    new AlertDialog.Builder(this)
            .setView(layout)
            .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(@NonNull DialogInterface dialog, int which) {
                    currentTileWidth = pickerWidth.getValue();
                    currentTileHeight = pickerHeight.getValue();
                    widget.setTileSize(-1);
                    widget.setTileWidthDp(currentTileWidth);
                    widget.setTileHeightDp(currentTileHeight);
                }
            })
            .show();
}
 
Example 18
Source File: NumberPickerPreference.java    From ForceDoze with GNU General Public License v3.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void showDialog() {
    if (mDialog == null) {

        View view = ((LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.view_number_picker_dialog, null);

        // build NumberPicker
        mPicker = (NumberPicker) view.findViewById(R.id.number_picker);
        if (mStep > 1) {
            mValues = new String[(mMax - mMin) / mStep + 1];
            for (int i = 0; i < mValues.length; i++) {
                mValues[i] = Integer.toString(mMin + mStep * i);
            }
            mPicker.setMinValue(0);
            mPicker.setMaxValue((mMax - mMin) / mStep);
            mPicker.setDisplayedValues(mValues);
        } else {
            mPicker.setMaxValue(mMax);
            mPicker.setMinValue(mMin);
            mPicker.setValue(mCurrentValue);
        }

        // build save button
        Button saveButton = (Button) view.findViewById(R.id.btn_save);
        saveButton.setOnClickListener(this);

        // build dialog
        mDialog = new AlertDialog.Builder(getContext())
                .setTitle(mTitle)
                .setView(view)
                .setCancelable(true)
                .create();

        mDialog.setCanceledOnTouchOutside(true);
    }

    mDialog.show();
}
 
Example 19
Source File: DayPickerPopup.java    From arcusandroid with Apache License 2.0 5 votes vote down vote up
@Override
public void doContentSection() {
    Calendar current = Calendar.getInstance();
    int DEFAULT_MAX_DAYS_TO_SHOW = 14;
    int maxDaysToShow = getNonNullArguments().getInt(MAX_DAYS, DEFAULT_MAX_DAYS_TO_SHOW);
    int dayAddOrSubtract = getNonNullArguments().getBoolean(DAYS_GOING_BACKWARDS, true) ? -1 : 1;
    String yesterdayTomorrowText = getString(getNonNullArguments().getBoolean(DAYS_GOING_BACKWARDS, true) ? R.string.yesterday : R.string.tomorrow);

    String[] days = new String[maxDaysToShow];

    for (int i = 0; i < maxDaysToShow; i++) {
        if (i > 1) {
            days[i] = headerDateFormat.format(current.getTime());
        }
        else {
            days[i] = i == 0 ? getString(R.string.today) : yesterdayTomorrowText;
        }
        current.add(Calendar.DAY_OF_MONTH, dayAddOrSubtract);
    }

    picker = (NumberPicker) contentView.findViewById(R.id.floating_day_number_picker);
    picker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
    picker.setMinValue(0);
    picker.setMaxValue(maxDaysToShow - 1);
    picker.setDisplayedValues(days);

    View divider = contentView.findViewById(R.id.picker_title_divider);
    if (divider != null) {
        divider.setVisibility(View.VISIBLE);
    }
}
 
Example 20
Source File: PickersFragment.java    From holoaccent with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
	View result = inflater.inflate(R.layout.pickers, null);

       NumberPicker nPicker1 = (NumberPicker)result.findViewById(R.id.numberPicker);
       nPicker1.setMinValue(0);
       nPicker1.setMaxValue(100);
       nPicker1.setValue(30);

       return result;
}