Java Code Examples for android.widget.NumberPicker#setMaxValue()
The following examples show how to use
android.widget.NumberPicker#setMaxValue() .
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: EditTvShowFragment.java From Mizuu with Apache License 2.0 | 6 votes |
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 2
Source File: DynamicSettersActivity.java From calendarview2 with MIT License | 6 votes |
@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 NightWatch with GNU General Public License v3.0 | 6 votes |
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: AlarmOffsetDialog.java From SuntimesWidget with GNU General Public License v3.0 | 6 votes |
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 5
Source File: SnoozeActivity.java From xDrip with GNU General Public License v3.0 | 6 votes |
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: AgeElement.java From sana.mobile with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override protected View createView(Context c) { LayoutInflater inflater = ((Activity) c).getLayoutInflater(); LinearLayout v = (LinearLayout) inflater.inflate(R.layout.widget_element_age, null); mWidget = (NumberPicker) v.findViewById(R.id.answer); mWidget.setMaxValue(120); mWidget.setMinValue(0); mWidget.setValue((int) age); mWidget.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() { @Override public void onValueChange(NumberPicker picker, int oldVal, int newVal) { setAge(newVal); } }); /* et = new EditText(c); et.setText(String.valueOf(age)); et.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); et.setKeyListener(new DigitsKeyListener()); */ //return encapsulateQuestion(c, et); return encapsulateQuestion(c, v); }
Example 7
Source File: SilenterPrompt.java From prayer-times-android with Apache License 2.0 | 6 votes |
@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 8
Source File: NumberPickerDialogPreference.java From android-quiz-php with BSD 2-Clause "Simplified" License | 5 votes |
@Override protected void onBindDialogView(View view) { super.onBindDialogView(view); TextView dialogMessageText = (TextView) view.findViewById(R.id.text_dialog_message); dialogMessageText.setText(getDialogMessage()); mNumberPicker = (NumberPicker) view.findViewById(R.id.number_picker); mNumberPicker.setMinValue(mMinValue); mNumberPicker.setMaxValue(mMaxValue); mNumberPicker.setValue(mValue); }
Example 9
Source File: PreferenceNagTimePicker.java From recurrence with GNU General Public License v3.0 | 5 votes |
protected void setUpSecondPicker(View view) { secondPicker = (NumberPicker) view.findViewById(R.id.picker2); secondPicker.setMaxValue(MAX_VALUE); secondPicker.setMinValue(MIN_VALUE); secondPicker.setValue(sharedPreferences.getInt("nagSeconds", getContext().getResources().getInteger(R.integer.default_nag_seconds))); String[] secondValues = new String[61]; for (int i = 0; i < secondValues.length; i++) { secondValues[i] = String.format(getContext().getResources().getQuantityString(R.plurals.time_second, i), i); } secondPicker.setDisplayedValues(secondValues); }
Example 10
Source File: PageSelectDialogFragment.java From something.apk with MIT License | 5 votes |
@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 11
Source File: NumberPickerPreference.java From ForceDoze with GNU General Public License v3.0 | 5 votes |
@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 12
Source File: DynamicSettersActivity.java From material-calendarview with MIT License | 5 votes |
@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 13
Source File: TestActivity.java From medical-data-android with GNU General Public License v3.0 | 5 votes |
/** * 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 14
Source File: DurationPicker.java From SightRemote with GNU General Public License v3.0 | 5 votes |
public DurationPicker(NumberPicker digit1, NumberPicker digit2) { this.digit1 = digit1; this.digit2 = digit2; digit1.setMinValue(0); digit1.setMaxValue(24); digit2.setMinValue(0); digit2.setMaxValue(3); digit2.setDisplayedValues(new String[] {"0", "15", "30", "45"}); digit1.setOnValueChangedListener(this); digit2.setOnValueChangedListener(this); }
Example 15
Source File: ChannelPickerPreference.java From sniffer154 with GNU General Public License v3.0 | 5 votes |
@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 16
Source File: NumberPickerPreference.java From AppOpsX with MIT License | 5 votes |
@Override protected void onBindDialogView(View view) { super.onBindDialogView(view); picker = (NumberPicker) view.findViewById(R.id.numpicker_pref); picker.setMaxValue(getNumberPickerPreference().maxValue); picker.setMinValue(getNumberPickerPreference().minValue); picker.setValue(currentValue); }
Example 17
Source File: OddDaysPopup.java From arcusandroid with Apache License 2.0 | 5 votes |
@Override public void doContentSection() { Calendar current = Calendar.getInstance(); String[] days = new String[7]; int j=0; int i=0; do { if ( (current.get(Calendar.DAY_OF_MONTH) & 1) == 0 ) { i++; } else { if (i > 1) { days[j] = headerDateFormat.format(current.getTime()); } else { days[j] = i == 0 ? getString(R.string.today) : getString(R.string.tomorrow); } j++; i++; } current.add(Calendar.DAY_OF_MONTH, 1); } while(i<14); picker = (NumberPicker) contentView.findViewById(R.id.floating_day_number_picker); picker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS); picker.setMinValue(0); picker.setMaxValue(6); picker.setDisplayedValues(days); }
Example 18
Source File: IrrigationZoneDurationFragment.java From arcusandroid with Apache License 2.0 | 4 votes |
private void updateTimeSelector() { String deviceAddress = getArguments().getString(MODEL_ADDR, ""); ModelSource<DeviceModel> m = DeviceModelProvider.instance().getModel(deviceAddress); m.addModelListener(Listeners.runOnUiThread(new Listener<ModelEvent>() { public void onEvent(ModelEvent e) { if (e instanceof ModelAddedEvent) { // model is loaded } } })); m.load(); if (m.get() != null) { deviceModel = m.get(); } Bundle args = getArguments(); if (args == null) { return; // Nothing to show... } try { bundleStrings = (ArrayList<StringPair>) args.getSerializable(SELECTIONS); if (bundleStrings == null) { return; // Again, nothing to show. } } catch (Exception ex) { logger.error("Could not deserialize SELECTIONS", ex); return; } String selectedValue = args.getString(SELECTED); int selectedIndex = -1; int bundleSize = bundleStrings.size(); String[] pickerValues = new String[bundleSize]; for (int i = 0; i < bundleSize; i++) { pickerValues[i] = bundleStrings.get(i).getValue(); if (bundleStrings.get(i).getKey().equals(selectedValue)) { selectedIndex = i; } } String abstractText = args.getString(ABSTRACT); if (!TextUtils.isEmpty(abstractText)) { TextView view = (TextView) contentView.findViewById(R.id.day_number_picker_abstract); if (view != null) { view.setText(abstractText); view.setVisibility(View.VISIBLE); } } boolean showDivider = args.getBoolean(DIVIDER, false); View divider = contentView.findViewById(R.id.picker_title_divider); if (showDivider) { if (divider != null) { divider.setVisibility(View.VISIBLE); } } else { if (divider != null) { divider.setVisibility(View.GONE); } } picker = (NumberPicker) contentView.findViewById(R.id.floating_day_number_picker); picker.setMinValue(0); picker.setMaxValue(bundleSize - 1); picker.setDisplayedValues(pickerValues); picker.setValue(selectedIndex != -1 ? selectedIndex : 0); }
Example 19
Source File: MainActivity.java From ScrollingPagerIndicator with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); int screenWidth = getScreenWidth(); // Setup ViewPager with indicator ViewPager pager = findViewById(R.id.pager); DemoPagerAdapter pagerAdapter = new DemoPagerAdapter(8); pager.setAdapter(pagerAdapter); ScrollingPagerIndicator pagerIndicator = findViewById(R.id.pager_indicator); pagerIndicator.attachToPager(pager); // Setup ViewPager2 with indicator ViewPager2 pager2 = findViewById(R.id.pager2); DemoRecyclerViewAdapter pagerAdapter2 = new DemoRecyclerViewAdapter(8, ViewGroup.LayoutParams.MATCH_PARENT); pager2.setAdapter(pagerAdapter2); ScrollingPagerIndicator pagerIndicator2 = findViewById(R.id.pager_indicator2); pagerIndicator2.attachToPager(pager2); // Setup RecyclerView with indicator // One page will occupy 1/3 of screen width RecyclerView recyclerView = findViewById(R.id.recycler); recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)); DemoRecyclerViewAdapter recyclerAdapter = new DemoRecyclerViewAdapter(8, screenWidth / 3); recyclerView.setAdapter(recyclerAdapter); recyclerView.setPadding(screenWidth / 3, 0, screenWidth / 3, 0); ScrollingPagerIndicator recyclerIndicator = findViewById(R.id.recycler_indicator); // Consider page in the middle current recyclerIndicator.attachToRecyclerView(recyclerView); SnapHelper snapHelper = new PagerSnapHelper(); snapHelper.attachToRecyclerView(recyclerView); // Some controls NumberPicker pageCountPicker = findViewById(R.id.page_number_picker); pageCountPicker.setMaxValue(99); pageCountPicker.setMinValue(0); pageCountPicker.setValue(pagerAdapter.getCount()); NumberPicker visibleDotCountPicker = findViewById(R.id.visible_dot_number_picker); visibleDotCountPicker.setMinValue(3); visibleDotCountPicker.setMaxValue(11); visibleDotCountPicker.setValue(pagerIndicator.getVisibleDotCount()); visibleDotCountPicker.setOnValueChangedListener((picker, oldVal, newVal) -> { if (newVal % 2 == 0) { Toast.makeText(this, "Visible dot count must be odd number", Toast.LENGTH_SHORT).show(); return; } pagerIndicator.setVisibleDotCount(newVal); recyclerIndicator.setVisibleDotCount(newVal); }); pageCountPicker.setOnValueChangedListener((picker, oldVal, newVal) -> { if (pager.getCurrentItem() >= newVal - 1) { pager.setCurrentItem(newVal - 1, false); } pagerAdapter.setCount(newVal); recyclerAdapter.setCount(newVal); }); }
Example 20
Source File: DynamicGridSizeFragment.java From Trebuchet with GNU General Public License v3.0 | 4 votes |
private void showNumberPicker() { mDialog = new Dialog(getActivity()); mDialog.setTitle(getResources().getString( R.string.preferences_interface_homescreen_custom)); mDialog.setContentView(R.layout.custom_grid_size_dialog); NumberPicker nPRows = (NumberPicker) mDialog.findViewById(R.id.custom_rows); NumberPicker nPColumns = (NumberPicker) mDialog.findViewById(R.id.custom_columns); InvariantDeviceProfile grid = getInvariantDeviceProfile(); int rows = grid.numRowsBase; int columns = grid.numColumnsBase; nPRows.setMinValue(Math.max(MIN_DYNAMIC_GRID_ROWS, rows - InvariantDeviceProfile.GRID_SIZE_MIN)); nPRows.setMaxValue(rows + InvariantDeviceProfile.GRID_SIZE_MAX); nPRows.setValue(mCustomGridRows); nPRows.setWrapSelectorWheel(false); nPRows.setOnValueChangedListener(this); nPRows.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS); nPColumns.setMinValue(Math.max(MIN_DYNAMIC_GRID_COLUMNS, columns - InvariantDeviceProfile.GRID_SIZE_MIN)); nPColumns.setMaxValue(columns + InvariantDeviceProfile.GRID_SIZE_MAX); nPColumns.setValue(mCustomGridColumns); nPColumns.setWrapSelectorWheel(false); nPColumns.setOnValueChangedListener(this); nPColumns.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS); Button button = (Button) mDialog.findViewById(R.id.dialog_confirm_button); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mDialog != null) { mDialog.dismiss(); } } }); mDialog.setOnDismissListener(this); mDialog.show(); }