List of usage examples for android.widget NumberPicker setWrapSelectorWheel
public void setWrapSelectorWheel(boolean wrapSelectorWheel)
From source file:com.lambdasoup.quickfit.ui.CaloriesDialogFragment.java
@NonNull @Override// w ww . j a v a 2s . c o m public Dialog onCreateDialog(Bundle savedInstanceState) { View dialogContent = LayoutInflater.from(getContext()).inflate(R.layout.dialog_calories, null); NumberPicker numberPicker = ((NumberPicker) dialogContent.findViewById(R.id.calories_picker)); numberPicker.setMinValue(0); numberPicker.setMaxValue(9999); numberPicker.setWrapSelectorWheel(false); numberPicker.setValue(getArguments().getInt(KEY_OLD_VALUE)); return new AlertDialog.Builder(getContext()).setView(dialogContent).setTitle(R.string.title_calories) .setPositiveButton(R.string.button_done_calories, this).setNegativeButton(R.string.cancel, this) .create(); }
From source file:com.lambdasoup.quickfit.ui.DurationMinutesDialogFragment.java
@NonNull @Override// ww w . j a va 2s .com public Dialog onCreateDialog(Bundle savedInstanceState) { View dialogContent = LayoutInflater.from(getContext()).inflate(R.layout.dialog_duration_minutes, null); NumberPicker numberPicker = ((NumberPicker) dialogContent.findViewById(R.id.duration_mins_picker)); numberPicker.setMinValue(1); numberPicker.setMaxValue(9999); numberPicker.setWrapSelectorWheel(false); numberPicker.setValue(getArguments().getInt(KEY_OLD_VALUE)); return new AlertDialog.Builder(getContext()).setView(dialogContent) .setTitle(R.string.title_workout_duration) .setPositiveButton(R.string.button_done_workout_duration, this) .setNegativeButton(R.string.cancel, this).create(); }
From source file:org.odk.collect.android.fragments.dialogs.NumberPickerDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.number_picker_dialog, null); final NumberPicker numberPicker = (NumberPicker) view.findViewById(R.id.number_picker); numberPicker.setMaxValue(((String[]) getArguments().getSerializable(DISPLAYED_VALUES)).length - 1); numberPicker.setMinValue(0);// ww w.j a v a 2s .c o m numberPicker.setWrapSelectorWheel(false); numberPicker.setDisplayedValues((String[]) getArguments().getSerializable(DISPLAYED_VALUES)); numberPicker.setValue(((String[]) getArguments().getSerializable(DISPLAYED_VALUES)).length - 1 - getArguments().getInt(PROGRESS)); return new AlertDialog.Builder(getActivity()).setTitle("Number Picker").setView(view) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { listener.onNumberPickerValueSelected(getArguments().getInt(WIDGET_ID), numberPicker.getValue()); } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { } }).create(); }
From source file:butter.droid.base.fragments.dialog.NumberPickerDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); if (getArguments() == null || !getArguments().containsKey(MAX_VALUE) || !getArguments().containsKey(MIN_VALUE) || !getArguments().containsKey(TITLE) || mOnResultListener == null) { return builder.create(); }/*from w ww. j av a 2s.c om*/ final NumberPicker numberPicker = new NumberPicker(getActivity()); numberPicker.setLayoutParams(new NumberPicker.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); numberPicker.setWrapSelectorWheel(false); final int minValue = getArguments().getInt(MIN_VALUE); final int maxValue = getArguments().getInt(MAX_VALUE); final int currentValue = getArguments().getInt(DEFAULT_VALUE, (int) Math.floor((numberPicker.getMaxValue() - numberPicker.getMinValue()) / 2)); List<String> displayValues = new ArrayList<>(); for (int i = minValue; i < maxValue + 1; i++) { displayValues.add(Integer.toString(i)); } numberPicker.setDisplayedValues(displayValues.toArray(new String[displayValues.size()])); if (minValue < 0) { numberPicker.setMinValue(0); numberPicker.setMaxValue(maxValue + Math.abs(minValue)); numberPicker.setValue(currentValue + Math.abs(minValue)); } else { numberPicker.setMinValue(minValue); numberPicker.setMaxValue(maxValue); numberPicker.setValue(currentValue); } if (getArguments().containsKey(FOCUSABLE) && !getArguments().getBoolean(FOCUSABLE)) numberPicker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS); builder.setView(numberPicker).setTitle(getArguments().getString(TITLE)) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { mOnResultListener.onNewValue(numberPicker.getValue() + (minValue < 0 ? minValue : 0)); dialog.dismiss(); } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); return builder.create(); }
From source file:com.crcrch.chromatictuner.app.NotePickerFragment.java
@NonNull @Override/*from w w w.j a v a2s .co m*/ public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getContext()); View dialogContent = LayoutInflater.from(dialogBuilder.getContext()).inflate(R.layout.fragment_note_picker, null); final NumberPicker notePicker = (NumberPicker) dialogContent.findViewById(R.id.picker_note); notePicker.setMinValue(0); notePicker.setMaxValue(MiscMusic.CHROMATIC_SCALE.length - 1); notePicker.setDisplayedValues(MiscMusic.CHROMATIC_SCALE); notePicker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS); final NumberPicker octavePicker = (NumberPicker) dialogContent.findViewById(R.id.picker_octave); octavePicker.setMinValue(0); octavePicker.setMaxValue(MAX_OCTAVE); octavePicker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS); octavePicker.setWrapSelectorWheel(false); final TextView frequencyView = (TextView) dialogContent.findViewById(R.id.frequency); notePicker.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() { @Override public void onValueChange(NumberPicker picker, int oldVal, int newVal) { frequencyView.setText(selectFrequency(newVal, octavePicker.getValue())); } }); octavePicker.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() { @Override public void onValueChange(NumberPicker picker, int oldVal, int newVal) { frequencyView.setText(selectFrequency(notePicker.getValue(), newVal)); } }); double frequencyToDisplay; if (savedInstanceState == null) { frequencyToDisplay = initialFrequency; } else { frequencyToDisplay = savedInstanceState.getDouble(STATE_FREQUENCY); } frequencyView.setText(selectFrequency(frequencyToDisplay)); int note = getNoteForFrequency(frequencyToDisplay); octavePicker.setValue(getOctaveForNote(note)); octavePicker.invalidate(); notePicker.setValue(getNoteIndexForNote(note)); notePicker.invalidate(); return dialogBuilder.setTitle(R.string.dialog_title_note_picker).setView(dialogContent) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { listener.onFrequencySelected(frequency); dialog.dismiss(); } }).setNegativeButton(android.R.string.cancel, null).create(); }
From source file:cz.maresmar.sfm.view.menu.MenuDetailsFragment.java
private void showPickerDialog(@StringRes int title, int min, int max, int value, IntConsumer newValueConsumer) { // Prepare number picker NumberPicker picker = new NumberPicker(getContext()); picker.setMinValue(min);// w ww.j a v a2 s . c o m picker.setMaxValue(max); picker.setValue(value); picker.setWrapSelectorWheel(false); FrameLayout layout = new FrameLayout(getContext()); layout.addView(picker, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.CENTER)); // Show alert new AlertDialog.Builder(getContext()).setTitle(title).setMessage(R.string.menu_detail_pick_new_value) .setView(layout).setPositiveButton(android.R.string.ok, (dialogInterface, i) -> { // do something with picker.getValue() newValueConsumer.accept(picker.getValue()); }).setNegativeButton(android.R.string.cancel, null).show(); }
From source file:com.jaguarlandrover.hvacdemo.MainActivity.java
private void configurePicker(NumberPicker picker) { picker.setMinValue(15);/* www. j av a2 s . c om*/ picker.setMaxValue(29); picker.setWrapSelectorWheel(false); picker.setDisplayedValues(new String[] { "LO", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "HI" }); picker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS); picker.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() { /* USER INTERFACE CALLBACK */ @Override public void onValueChange(NumberPicker picker, int oldVal, int newVal) { Log.d(TAG, Util.getMethodName()); HVACManager.invokeService(getServiceIdentifiersFromViewId(picker.getId()), Integer.toString(newVal)); } }); }
From source file:org.ciasaboark.tacere.activity.fragment.AdvancedSettingsFragment.java
private void drawEventBufferWidgets() { LinearLayout bufferBox = (LinearLayout) rootView.findViewById(R.id.advanced_settings_buffer_box); bufferBox.setOnClickListener(new View.OnClickListener() { @Override/*from w w w . j ava 2s.co m*/ public void onClick(View v) { AlertDialog.Builder builder = new AlertDialog.Builder( new ContextThemeWrapper(context, R.style.Dialog)); builder.setTitle("Buffer Minutes"); final NumberPicker number = new NumberPicker(context); String[] nums = new String[32]; for (int i = 0; i < nums.length; i++) { nums[i] = Integer.toString(i); } number.setMinValue(1); number.setMaxValue(nums.length - 1); number.setWrapSelectorWheel(false); number.setDisplayedValues(nums); number.setValue(prefs.getBufferMinutes() + 1); builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { prefs.setBufferMinutes(number.getValue() - 1); drawEventBufferWidgets(); } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Do nothing } }); builder.setView(number); AlertDialog dialog = builder.show(); } }); // the event buffer button TextView bufferTV = (TextView) rootView.findViewById(R.id.bufferMinutesDescription); String bufferText = getResources().getString(R.string.advanced_settings_section_intervals_buffer_duration); bufferTV.setText(String.format(bufferText, prefs.getBufferMinutes())); }
From source file:it.durip_app.ExperimentMasterActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); s = new String[3]; setContentView(R.layout.activity_experiment_master); setupActionBar();//from w ww. j ava 2 s . com boxAdapter = new IpListAdapter(this, managedIps); ListView lvMain = (ListView) findViewById(R.id.IpListToManage); lvMain.setAdapter(boxAdapter); // final View controlsView = findViewById(R.id.fullscreen_content_controls); // final View contentView = findViewById(R.id.fullscreen_content); NumberPicker ip1 = (NumberPicker) findViewById(R.id.ip1); NumberPicker ip2 = (NumberPicker) findViewById(R.id.ip2); NumberPicker ip3 = (NumberPicker) findViewById(R.id.ip3); NumberPicker ip4 = (NumberPicker) findViewById(R.id.ip4); ip1.setMinValue(1); ip1.setMaxValue(254); ip1.setWrapSelectorWheel(true); ip2.setMinValue(0); ip2.setMaxValue(254); ip2.setWrapSelectorWheel(true); ip3.setMinValue(0); ip3.setMaxValue(254); ip3.setWrapSelectorWheel(true); ip4.setMinValue(0); ip4.setMaxValue(254); ip4.setWrapSelectorWheel(true); BufferedReader br; String newIp; boolean addme; try { br = new BufferedReader(new FileReader(fileIPExperiment)); while ((newIp = br.readLine()) != null) { addme = true; // if already in the list do not add another one if (managedIps.contains(new ManagedIp(newIp, newIp, true))) addme = false; Log.d("managermanager", "writing"); if (addme) { managedIps.add(new ManagedIp(newIp, newIp, true)); } } br.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } /* // Set up an instance of SystemUiHider to control the system UI for // this activity. mSystemUiHider = SystemUiHider.getInstance(this, contentView, HIDER_FLAGS); mSystemUiHider.setup(); mSystemUiHider .setOnVisibilityChangeListener(new SystemUiHider.OnVisibilityChangeListener() { // Cached values. int mControlsHeight; int mShortAnimTime; @Override @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2) public void onVisibilityChange(boolean visible) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { // If the ViewPropertyAnimator API is available // (Honeycomb MR2 and later), use it to animate the // in-layout UI controls at the bottom of the // screen. if (mControlsHeight == 0) { mControlsHeight = controlsView.getHeight(); } if (mShortAnimTime == 0) { mShortAnimTime = getResources().getInteger( android.R.integer.config_shortAnimTime); } controlsView .animate() .translationY(visible ? 0 : mControlsHeight) .setDuration(mShortAnimTime); } else { // If the ViewPropertyAnimator APIs aren't // available, simply show or hide the in-layout UI // controls. controlsView.setVisibility(visible ? View.VISIBLE : View.GONE); } if (visible && AUTO_HIDE) { // Schedule a hide(). delayedHide(AUTO_HIDE_DELAY_MILLIS); } } }); // Set up the user interaction to manually show or hide the system UI. contentView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (TOGGLE_ON_CLICK) { mSystemUiHider.toggle(); } else { mSystemUiHider.show(); } } }); // Upon interacting with UI controls, delay any scheduled hide() // operations to prevent the jarring behavior of controls going away // while interacting with the UI. findViewById(R.id.startexperiment).setOnTouchListener( mDelayHideTouchListener);*/ }
From source file:com.sean.takeastand.ui.MainActivity.java
private void showPauseSettingsDialog() { LayoutInflater inflater = getLayoutInflater(); AlertDialog.Builder builder = new AlertDialog.Builder(this); View dialogView = inflater.inflate(R.layout.dialog_pause, null); TextView title = new TextView(this); title.setPadding(50, 50, 50, 50);/* w ww .ja v a 2 s . c om*/ title.setTextSize(22); title.setTextColor(getResources().getColor(android.R.color.holo_blue_light)); title.setText(getResources().getString(R.string.select_pause_type)); builder.setCustomTitle(title); String[] valueSet = new String[pauseTimes.length]; for (int i = 0; i < pauseTimes.length; i++) { valueSet[i] = Integer.toString(pauseTimes[i]); } builder.setView(dialogView); final NumberPicker npPause = (NumberPicker) dialogView.findViewById(R.id.pauseNumberPicker); npPause.setDisplayedValues(valueSet); npPause.setMinValue(0); npPause.setMaxValue(valueSet.length - 1); npPause.setWrapSelectorWheel(false); int initialValue = Utils.getDefaultPauseAmount(this); for (int i = 0; i < pauseTimes.length; i++) { if (initialValue == pauseTimes[i]) { initialValue = i; } } npPause.setValue(initialValue); builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { //getValue returns the index number, so need to do some math to correct correct //actual value setDefaultPauseAmount(pauseTimes[npPause.getValue()]); int currentStatus = Utils.getImageStatus(MainActivity.this); if (currentStatus == Constants.NON_SCHEDULE_ALARM_RUNNING || currentStatus == Constants.NON_SCHEDULE_STOOD_UP || currentStatus == Constants.NON_SCHEDULE_TIME_TO_STAND) { pauseUnscheduled(); } else { pauseSchedule(); sendAnalyticsEvent("Paused"); } dialogInterface.dismiss(); } }); builder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { mPausePlay.setIcon(getResources().getDrawable(R.drawable.ic_action_pause)); } }); AlertDialog alertDialog = builder.create(); alertDialog.show(); }