Example usage for android.widget NumberPicker getValue

List of usage examples for android.widget NumberPicker getValue

Introduction

In this page you can find the example usage for android.widget NumberPicker getValue.

Prototype

public int getValue() 

Source Link

Document

Returns the value of the picker.

Usage

From source file:ca.mudar.parkcatcher.ui.fragments.NumberPickerFragment.java

/**
 * Update the app's duration value// w  w  w. j a  va2  s.com
 * 
 * @param seekbar
 */
private void onDurationSet(NumberPicker numberPicker) {
    int duration = numberPicker.getValue();
    mListener.setParkingDuration(duration);
}

From source file:com.villetainio.travelcardreminder.fragments.SettingsFragment.java

private void saveValues(View view) {
    SharedPreferences.Editor editor = cardStorage.edit();

    // Enable notifications
    editor.putBoolean(getString(R.string.settings_enable_notifications),
            ((CheckBox) view.findViewById(R.id.enable_notifications)).isChecked());

    // Days before
    NumberPicker numberPicker = (NumberPicker) view.findViewById(R.id.days_pick);
    editor.putInt(getString(R.string.settings_days), numberPicker.getValue());

    // Time to start
    TimePicker timePicker = (TimePicker) view.findViewById(R.id.time_pick);
    editor.putInt(getString(R.string.settings_hours), timePicker.getCurrentHour());
    editor.putInt(getString(R.string.settings_minutes), timePicker.getCurrentMinute());

    editor.apply();//from  w  w  w .  j av a 2 s.co m
}

From source file:com.lambdasoup.quickfit.ui.CaloriesDialogFragment.java

@Override
public void onClick(DialogInterface dialog, int which) {
    switch (which) {
    case DialogInterface.BUTTON_POSITIVE:
        NumberPicker numberPicker = ((NumberPicker) getDialog().findViewById(R.id.calories_picker));
        numberPicker.clearFocus();//  www.j av  a  2s. c o m
        int newVal = numberPicker.getValue();
        listener.onCaloriesChanged(getArguments().getLong(KEY_WORKOUT_ID), newVal);
        break;
    case DialogInterface.BUTTON_NEGATIVE:
        break;
    default:
        throw new IllegalStateException("No such button.");
    }
}

From source file:com.lambdasoup.quickfit.ui.DurationMinutesDialogFragment.java

@Override
public void onClick(DialogInterface dialog, int which) {
    switch (which) {
    case DialogInterface.BUTTON_POSITIVE:
        NumberPicker numberPicker = ((NumberPicker) getDialog().findViewById(R.id.duration_mins_picker));
        numberPicker.clearFocus();/* w  w  w  . j  a  v  a  2s . c om*/
        int newVal = numberPicker.getValue();
        listener.onDurationChanged(getArguments().getLong(KEY_WORKOUT_ID), newVal);
        break;
    case DialogInterface.BUTTON_NEGATIVE:
        break;
    default:
        throw new IllegalStateException("No such button.");
    }
}

From source file:org.tomasdavid.vehicleroutingproblem.components.OpenFileButton.java

/**
 * {@inheritDoc}/*from  w  ww .ja v a 2  s.c o  m*/
 */
@Override
public void onClick(View v) {
    FragmentActivity activity = (FragmentActivity) v.getContext();
    NumberPicker numberPicker = (NumberPicker) activity.findViewById(R.id.timeLimitPicker);
    Spinner algSpinner = (Spinner) activity.findViewById(R.id.algorithm_spinner);

    // add setting values to bundle and starts new fragment
    Bundle bundle = new Bundle();
    bundle.putInt(VrpKeys.VRP_TIME_LIMIT.name(), numberPicker.getValue());
    bundle.putString(VrpKeys.VRP_ALGORITHM.name(), activity.getResources()
            .obtainTypedArray(R.array.algorithm_files).getString(algSpinner.getSelectedItemPosition()));
    VrpFileListFragment fragment = new VrpFileListFragment();
    fragment.setArguments(bundle);
    activity.getSupportFragmentManager().beginTransaction().replace(R.id.activity_main, fragment)
            .addToBackStack(null).commit();
}

From source file:com.matthewmitchell.wakeifyplus.NumberPickerFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    final NumberPicker np = new NumberPicker(activity);
    np.setMaxValue(60);//from   www . jav a  2 s  . c o m
    np.setMinValue(1);
    np.setValue(defaultNum);

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setMessage("Set Snooze Minutes").setView(np)
            .setPositiveButton("Set", new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    activity.snoozeMinutes = np.getValue();
                    TextView edit = (TextView) activity.findViewById(R.id.snooze_edit);
                    edit.setText("" + activity.snoozeMinutes);
                }
            }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    // Do nothing.
                }
            });
    // Create the AlertDialog object and return it
    return builder.create();

}

From source file:it.durip_app.ExperimentMasterActivity.java

public void addStation(View view) {
    boolean addme = true;
    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);
    String newIp = ip1.getValue() + "." + ip2.getValue() + "." + ip3.getValue() + "." + ip4.getValue();
    /*/*from w w  w  . ja  v  a  2s .  c o m*/
     ListView ipList = (ListView)findViewById(R.id.IpToManage);
     long[] listIp = ipList.getCheckedItemIds();
     for (int i = 0; i < listIp.length;i++){
        if(newIp.equals(ipList.getItemAtPosition((int)(listIp[i])))){
     addme = false;
        }
     }
     */
    if (managedIps.contains(new ManagedIp(newIp, newIp, true)))
        addme = false;
    if (addme) {
        managedIps.add(new ManagedIp(newIp, newIp, true));
    }
}

From source file:com.example.stephenhite.dndnextgen.CharCreateActivity.java

public void HandleCreateCharacter(View view) {
    TextView nameBox = (TextView) findViewById(R.id.character_name_field);
    NumberPicker ageBox = (NumberPicker) findViewById(R.id.character_age_field);
    NumberPicker heightPicker = (NumberPicker) findViewById(R.id.character_height_picker);
    NumberPicker weightPicker = (NumberPicker) findViewById(R.id.character_weight_picker);
    Spinner alignmentBox = (Spinner) findViewById(R.id.character_alignment_spinner);

    creatorCntl.userCharacter.setName(nameBox.getText().toString());
    creatorCntl.userCharacter.setAge(ageBox.getValue());
    creatorCntl.userCharacter.setHeight(heightPicker.getValue());
    creatorCntl.userCharacter.setWeight(weightPicker.getValue());
    creatorCntl.userCharacter.setAlignment(alignmentBox.getSelectedItem().toString());

    creatorCntl.saveCharacter(this.getBaseContext());
}

From source file:de.anycook.einkaufszettel.activities.AddIngredientsActivity.java

public void onNumberPickerClick(View view) {

    final EditText personsEditText = (EditText) view;
    int numPersons = Integer.parseInt(personsEditText.getText().toString());

    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
    alertDialogBuilder.setMessage(R.string.for_x_people);

    View alertDialogContent = LayoutInflater.from(alertDialogBuilder.getContext())
            .inflate(R.layout.number_picker_dialog, this.ingredientListView, false);

    final NumberPicker numberPicker = (NumberPicker) alertDialogContent
            .findViewById(R.id.number_picker_dialog_numberpicker);
    numberPicker.setMaxValue(MAX_PERSONS);
    numberPicker.setValue(numPersons);//  w w w .  j a  va2s .  c o m
    numberPicker.setMinValue(MIN_PERSONS);

    alertDialogBuilder.setView(alertDialogContent);

    alertDialogBuilder.setPositiveButton(R.string.set, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            String personsString = Integer.toString(numberPicker.getValue());
            personsEditText.setText(personsString);
            if (personsString.length() == 0) {
                return;
            }
            int numPersons = Integer.parseInt(personsEditText.getText().toString());
            ((IngredientRowAdapter) ingredientListView.getAdapter()).setCurrentPersons(numPersons);
        }
    });
    alertDialogBuilder.setNegativeButton(R.string.cancel, null);

    AlertDialog alertDialog = alertDialogBuilder.create();
    alertDialog.show();

}

From source file:com.crcrch.chromatictuner.app.NotePickerFragment.java

@NonNull
@Override/* ww w  .  j a  va 2 s.com*/
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();
}