Java Code Examples for android.widget.NumberPicker#setValue()
The following examples show how to use
android.widget.NumberPicker#setValue() .
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: 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 2
Source File: EditMovieFragment.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 mMovie.setRuntime(numberPicker.getValue()); // Update the UI with the new value setupValues(false); // Dismiss the dialog dialog.cancel(); } }); builder.show(); }
Example 3
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 4
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 5
Source File: CustomTileDimensions.java From calendarview2 with MIT License | 6 votes |
@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 6
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 7
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 8
Source File: DynamicSettersActivity.java From material-calendarview 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 9
Source File: Dialogs.java From Aegis with GNU General Public License v3.0 | 6 votes |
public static void showNumberPickerDialog(Activity activity, NumberInputListener listener) { View view = activity.getLayoutInflater().inflate(R.layout.dialog_number_picker, null); NumberPicker numberPicker = view.findViewById(R.id.numberPicker); numberPicker.setMinValue(3); numberPicker.setMaxValue(60); numberPicker.setValue(new Preferences(activity.getApplicationContext()).getTapToRevealTime()); numberPicker.setWrapSelectorWheel(true); 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 10
Source File: TimeIntervalPreference.java From chronosnap with MIT License | 6 votes |
/** * 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 11
Source File: EditTvShowEpisodeFragment.java From Mizuu with Apache License 2.0 | 5 votes |
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 mEpisode.setRating(numberPicker.getValue()); // Update the UI with the new value setupValues(false); // Dismiss the dialog dialog.cancel(); } }); builder.show(); }
Example 12
Source File: NumberPickerPreferenceFragmentCompat.java From libcommon with Apache License 2.0 | 5 votes |
@Override protected View onCreateDialogView(final Context context) { if (DEBUG) Log.v(TAG, "onCreateDialogView:"); final NumberPicker picker = new NumberPicker(context); picker.setOnValueChangedListener(mOnValueChangeListener); picker.setMinValue(mMinValue); picker.setMaxValue(mMaxValue); picker.setValue(mValue); changed = false; return picker; }
Example 13
Source File: DynamicSettersActivity.java From calendarview2 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 14
Source File: SyncPopup.java From haxsync with GNU General Public License v2.0 | 5 votes |
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.sync_freq_popup); prefs = PreferenceManager.getDefaultSharedPreferences(this); days = (NumberPicker) findViewById(R.id.Days); hours = (NumberPicker) findViewById(R.id.Hours); minutes = (NumberPicker) findViewById(R.id.Minutes); days.setMaxValue(365); hours.setMaxValue(23); minutes.setMaxValue(59); days.setValue(1); long sync_seconds = prefs.getLong("sync_seconds", 86400); if (sync_seconds != 86400){ int[] time = secondsToTime(sync_seconds); days.setValue(time[0]); hours.setValue(time[1]); minutes.setValue(time[2]); } OkButton = (Button) findViewById(R.id.OK); OkButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { setSyncRate(getSeconds()); //Log.i("SECONDS", Long.toString(getSeconds())); SyncPopup.this.finish(); } }); }
Example 15
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 16
Source File: EventReminder.java From haxsync with GNU General Public License v2.0 | 5 votes |
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.event_reminder); prefs = PreferenceManager.getDefaultSharedPreferences(this); days = (NumberPicker) findViewById(R.id.Days); hours = (NumberPicker) findViewById(R.id.Hours); minutes = (NumberPicker) findViewById(R.id.Minutes); days.setMaxValue(365); hours.setMaxValue(23); minutes.setMaxValue(59); minutes.setValue(30); long reminder_minutes = prefs.getLong("event_reminder_minutes", 30); if (reminder_minutes != 30){ int[] time = minutesToTime(reminder_minutes); days.setValue(time[0]); hours.setValue(time[1]); minutes.setValue(time[2]); } OkButton = (Button) findViewById(R.id.OK); OkButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { SharedPreferences.Editor editor = prefs.edit(); editor.putLong("event_reminder_minutes", getMinutes()); editor.commit(); AccountManager am = AccountManager.get(EventReminder.this); Account account = am.getAccountsByType("org.mots.haxsync.account")[0]; new EventReminder.ReminderUpdater(EventReminder.this, account, getMinutes()).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR, EventReminder.this.getString(R.string.event_cal)); EventReminder.this.finish(); } }); }
Example 17
Source File: EditTvShowFragment.java From Mizuu with Apache License 2.0 | 5 votes |
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 18
Source File: HoursMinutePickerFragment.java From arcusandroid with Apache License 2.0 | 4 votes |
@Override public void doContentSection() { 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); } } 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: NumberPickerBinding.java From android-utils with MIT License | 4 votes |
@Override public void run(Integer data, NumberPicker view) { if (view != null) view.setValue(data); }
Example 20
Source File: PersianDatePicker.java From Smartlab with Apache License 2.0 | 4 votes |
public PersianDatePicker(final Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View root = inflater.inflate(R.layout.pdp, this); yearNumberPicker = (NumberPicker) root .findViewById(R.id.yearNumberPicker); monthNumberPicker = (NumberPicker) root .findViewById(R.id.monthNumberPicker); dayNumberPicker = (NumberPicker) root .findViewById(R.id.dayNumberPicker); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PersianDatePicker, 0, 0); int year = 1393,month=6,day=19; year = a.getInteger(R.styleable.PersianDatePicker_year, 1393); month = a.getInteger(R.styleable.PersianDatePicker_month, 6); day = a.getInteger(R.styleable.PersianDatePicker_day, 19); a.recycle(); yearNumberPicker.setMinValue(1380); yearNumberPicker.setMaxValue(1400); yearNumberPicker.setValue(year); monthNumberPicker.setMinValue(1); monthNumberPicker.setMaxValue(12); monthNumberPicker.setValue(month); dayNumberPicker.setMaxValue(31); dayNumberPicker.setMinValue(1); dayNumberPicker.setValue(day); yearNumberPicker.setOnValueChangedListener(new OnValueChangeListener() { @Override public void onValueChange(NumberPicker np, int oldValue, int newValue) { Toast.makeText(context, "Year changed:" + oldValue + " -> " + newValue, Toast.LENGTH_LONG).show(); } }); }