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

The following examples show how to use android.widget.NumberPicker#setWrapSelectorWheel() . 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: 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 2
Source File: DynamicSettersActivity.java    From material-calendarview with MIT License 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: 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 4
Source File: SnoozeActivity.java    From xDrip-Experimental 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 5
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 6
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 7
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 8
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 9
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 10
Source File: DynamicSettersActivity.java    From calendarview2 with MIT License 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 11
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 12
Source File: SetTimerFragment.java    From Rainville with MIT License 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_set_timer, null);
    if (view != null) {
        mNumberPicker = (NumberPicker) view.findViewById(R.id.timeout_picker);

        String[] values = getDisplayedValues();
        mNumberPicker.setMaxValue(values.length - 1);
        mNumberPicker.setWrapSelectorWheel(false);
        mNumberPicker.setDisplayedValues(values);
    }

    return view;
}
 
Example 13
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 14
Source File: TestActivity.java    From medical-data-android with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Customizes the options shown in the {@link NumberPicker}s to represent i with the string
 * i - 1 and 0 with a blank option
 *
 * @param id
 */
private void prepareNumberPicker(int id) {
    NumberPicker np = (NumberPicker) findViewById(id);
    np.setMinValue(0);
    np.setMaxValue(1001);
    np.setWrapSelectorWheel(false);
    np.setFormatter(new NumberPicker.Formatter() {
        @Override
        public String format(int i) {
            if (i == 0) return " ";
            return String.valueOf(i - 1);
        }
    });
}
 
Example 15
Source File: TestActivity.java    From medical-data-android with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Customizes the options shown in the {@link NumberPicker}s to represent i with the string
 * (i - 1) * 10 and 0 with a blank option. That means that the step for the caffeine is 10
 * instead of 1
 *
 * @param id
 */
private void prepareCaffeineNumberPicker(int id) {
    NumberPicker np = (NumberPicker) findViewById(id);
    np.setMinValue(0);
    np.setMaxValue(10010);
    np.setWrapSelectorWheel(false);
    np.setFormatter(new NumberPicker.Formatter() {
        @Override
        public String format(int i) {
            if (i == 0) return " ";
            return String.valueOf((i - 1) * 10);
        }
    });
}
 
Example 16
Source File: NumberPickerFragment.java    From syncthing-android with Mozilla Public License 2.0 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    mNumberPicker = (NumberPicker) inflater.inflate(R.layout.numberpicker_fragment, container, false);
    mNumberPicker.setWrapSelectorWheel(false);

    return mNumberPicker;
}
 
Example 17
Source File: ChannelPickerPreference.java    From sniffer154 with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onBindDialogView(View view) {
	super.onBindDialogView(view);
	mNumberPicker = (NumberPicker) view.findViewById(R.id.numberPicker);
	mNumberPicker.setMaxValue(26);
	mNumberPicker.setMinValue(11);
	mNumberPicker.setValue(getPersistedInt(11));
	mNumberPicker.setWrapSelectorWheel(false);
}
 
Example 18
Source File: PageSelectDialogFragment.java    From something.apk with MIT License 5 votes vote down vote up
@Override
public void viewCreated(View frag, Bundle savedInstanceState) {
    Bundle args = getArguments();
    int current = args.getInt("current");
    maxPage = args.getInt("max");

    picker = (NumberPicker) frag.findViewById(R.id.page_number_picker);
    picker.setMinValue(1);
    picker.setMaxValue(maxPage);
    picker.setValue(current);
    picker.setWrapSelectorWheel(false);
    frag.findViewById(R.id.page_select_button).setOnClickListener(this);
    frag.findViewById(R.id.page_select_first).setOnClickListener(this);
    frag.findViewById(R.id.page_select_last).setOnClickListener(this);
}
 
Example 19
Source File: MultiTickButton.java    From tickmate with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean onLongClick(View v) {
	if (!ButtonHelpers.isCheckChangePermitted(getContext(), date)) {
		Toast.makeText(getContext(), R.string.notify_user_ticking_disabled, Toast.LENGTH_LONG).show();
		return false;
	}

       SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getContext());
	String longClickPref = sharedPrefs.getString("long-click-key", "LONGCLICK_DECREMENT");

	if (longClickPref.equals("LONGCLICK_PICK_VALUE")) {

		final View vFinal = v;  // view must be final to be accessed by inner class (performClick())
		final int oldValue = DataSource.getInstance().getTicksForDay(this.getTrack(), this.getDate()).size();
           final NumberPicker np = new NumberPicker(v.getContext());
           np.setMinValue(0);
           np.setMaxValue(99);
		np.setWrapSelectorWheel(false);
		np.setValue(oldValue);

		java.text.DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(v.getContext());

           new AlertDialog.Builder(v.getContext())
				.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
					@Override
					public void onClick(DialogInterface dialog, int which) {
						int newValue = np.getValue();
						if (newValue > oldValue){
							for( int i = oldValue; i < newValue; i++ ){
								vFinal.performClick();
							}
						} else if (newValue < oldValue){
							for( int i = oldValue; i > newValue; i-- ){
								DataSource.getInstance().removeLastTickOfDay(getTrack(), getDate());
							}
							updateStatus();
						}
					}
				})
				.setView(np)
				.setIcon(track.getIconId(v.getContext()))
				.setTitle(getResources().getString(R.string.set_number_of_ticks, dateFormat.format(date.getTime())))
				.show()
				// the next line doesn't wrap the dialog but rather keeps the dialog open when rotating the
				// device, without it the dialog disappears upon rotation (see also stackoverflow.com/questions/14907104)
				.getWindow().setLayout(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);


       } else {

           boolean success = DataSource.getInstance().removeLastTickOfDay(this.getTrack(), this.getDate());

           if (success) {
               updateStatus();
               Toast.makeText(this.getContext(), R.string.tick_deleted, Toast.LENGTH_SHORT).show();
           }
       }

	return true;
}
 
Example 20
Source File: NumberPickerPreference.java    From CrimeTalk-Reader with Apache License 2.0 2 votes vote down vote up
@Override
@SuppressLint("InflateParams")
protected View onCreateDialogView() {

    final LayoutInflater layoutInflater = (LayoutInflater)
            getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    final View view = layoutInflater.inflate(R.layout.preference_numberpicker, null);

    mNumberPicker = (NumberPicker) view.findViewById(R.id.number_picker);

    mNumberPicker.setMaxValue(25);
    mNumberPicker.setMinValue(5);
    mNumberPicker.setValue(getPersistedInt(10));
    mNumberPicker.setWrapSelectorWheel(false);
    mNumberPicker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);

    // There's a bug in the text color, correct it manually
    if (mNumberPicker.getChildCount() >= 1) {

        final View childView = mNumberPicker.getChildAt(1);

        if (childView != null && childView instanceof TextView) {

            if (PreferenceUtils.getDarkTheme(getContext())) {

                ((TextView) childView).setTextColor(getContext().getResources().getColor(R.color.white));

            } else {

                ((TextView) childView).setTextColor(getContext().getResources().getColor(R.color.black));

            }

        }

    }

    return view;

}