@Override
 public void onClick(DialogInterface dialog, int which) {
   if (listener != null) {
     numberPicker.clearFocus();
     listener.onNumberSet(numberPicker, numberPicker.getValue());
   }
 }
 public void numberPickerSetup(NumberPicker currentNumberPicker, int setValue) {
   currentNumberPicker.setMaxValue(listOfNumbers.length - 1);
   currentNumberPicker.setMinValue(0);
   currentNumberPicker.setWrapSelectorWheel(false);
   currentNumberPicker.setValue(setValue + 1);
   currentNumberPicker.setDisplayedValues(listOfNumbers);
 }
  /**
   * @param context Parent.
   * @param theme the theme to apply to this dialog
   * @param callBack How parent is notified.
   * @param number The initial number.
   */
  private NumberPickerDialog(
      Context context,
      int theme,
      OnNumberSetListener callBack,
      int number,
      int rangeMin,
      int rangeMax,
      int title,
      int units,
      int dialogId) {
    super(context, theme);
    mCallback = callBack;
    mDialogId = dialogId;

    setTitle(title);

    setButton(DialogInterface.BUTTON_POSITIVE, context.getText(R.string.ok), this);
    LayoutInflater inflater =
        (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.number_picker_dialog, null);
    setView(view);
    mNumberPicker = (NumberPicker) view.findViewById(R.id.number_picker);

    if (units != 0) {
      TextView unit = (TextView) view.findViewById(R.id.unit);
      unit.setText(units);
      unit.setVisibility(View.VISIBLE);
    }

    // initialize state
    mNumberPicker.setMinValue(rangeMin);
    mNumberPicker.setMaxValue(rangeMax);
    mNumberPicker.setValue(number);
  }
Example #4
0
 @Override
 public void setEnabled(boolean enabled) {
   super.setEnabled(enabled);
   mDayPicker.setEnabled(enabled);
   mMonthPicker.setEnabled(enabled);
   mYearPicker.setEnabled(enabled);
 }
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   int minimumForAmber = 0, minimumForRed = 0;
   super.onCreate(savedInstanceState);
   //        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
   //                WindowManager.LayoutParams.FLAG_FULLSCREEN);
   setContentView(R.layout.activity_advanced_speeches_timer_setting);
   setTitle("Select Time");
   final NumberPicker greenNumberPicker = (NumberPicker) findViewById(R.id.numberPicker);
   final NumberPicker amberNumberPicker = (NumberPicker) findViewById(R.id.numberPicker2);
   final NumberPicker redNumberPicker = (NumberPicker) findViewById(R.id.numberPicker3);
   numberPickerSetup(greenNumberPicker, 0);
   greenNumberPicker.setOnValueChangedListener(
       new NumberPicker.OnValueChangeListener() {
         @Override
         public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
           numberPickerSetup(amberNumberPicker, newVal);
           amberNumberPicker.setOnValueChangedListener(
               new NumberPicker.OnValueChangeListener() {
                 @Override
                 public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
                   numberPickerSetup(redNumberPicker, newVal);
                 }
               });
         }
       });
 }
Example #6
0
 private void set12HourShown(boolean shown) {
   if (shown) {
     mAMPMSpinner.setVisibility(VISIBLE);
   } else {
     mAMPMSpinner.setVisibility(GONE);
   }
 }
Example #7
0
 private GameType getGameType() {
   NumberPicker np = getNumberPicker();
   int wordLength = np.getValue();
   Spinner gameTypeSpinner = getGameTypeSpinner();
   String gameTypeStr = gameTypeSpinner.getSelectedItem().toString();
   return new GameType(wordLength, gameTypeStr);
 }
  private void show(final String stdUser) {
    final Dialog d = new Dialog(ViewEnrolledStdUpdateScoreActivity.this);
    d.setTitle("NumberPicker");
    d.setContentView(R.layout.layout_number_picker);
    Button b1 = (Button) d.findViewById(R.id.button1);
    Button b2 = (Button) d.findViewById(R.id.button2);
    final NumberPicker np = (NumberPicker) d.findViewById(R.id.numberPicker1);
    np.setMaxValue(100); // max value 100
    np.setMinValue(0); // min value 0
    np.setWrapSelectorWheel(false);

    b1.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            updateScore(stdUser, np.getValue());
            d.dismiss();
          }
        });

    b2.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            d.dismiss(); // dismiss the dialog
          }
        });

    d.show();
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    String name = getArguments().getString(NAME);
    String description = getArguments().getString(DESCRIPTION);
    Log.d("Fragment", pageId + "");
    View v = inflater.inflate(R.layout.fragment_vote, container, false);
    title = (TextView) v.findViewById(R.id.titleText);
    des = (TextView) v.findViewById(R.id.desText);
    title.setText(name);
    des.setText(description);
    np = (NumberPicker) v.findViewById(R.id.numberPicker);
    np.setMaxValue(value + left);
    np.setValue(value);
    np.setOnValueChangedListener(
        new OnValueChangeListener() {

          @Override
          public void onValueChange(NumberPicker arg0, int arg1, int arg2) {
            value = arg2;
            voteActivity.valueChange();
          }
        });
    return v;
  }
Example #10
0
 private void updateDaySpinner() {
   Calendar cal = Calendar.getInstance();
   // if year was not set, use 2000 as it was a leap year
   cal.set(mHasYear ? mYear : 2000, mMonth, 1);
   int max = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
   mDayPicker.setRange(1, max);
   mDayPicker.setCurrent(mDay);
 }
Example #11
0
 public NumberPicker setupSpinner(int id, int min, int max) {
   NumberPicker mSpinner = (NumberPicker) findViewById(id);
   mSpinner.setMinValue(min);
   mSpinner.setMaxValue(max);
   mSpinner.setOnValueChangedListener(mOnChangeListener);
   mSpinner.setOnLongPressUpdateInterval(100);
   return mSpinner;
 }
Example #12
0
 @Override
 protected void onBindDialogView(View view) {
   super.onBindDialogView(view);
   picker.setMinValue(MIN_VALUE);
   picker.setMaxValue(MAX_VALUE);
   picker.setWrapSelectorWheel(WRAP_SELECTOR_WHEEL);
   picker.setValue(getValue());
 }
 @Override
 protected void onDialogClosed(boolean positiveResult) {
   if (positiveResult) {
     // needed when user edits the text field and clicks OK
     mPicker.clearFocus();
     setValue(mPicker.getValue());
   }
 }
 @Override
 public void onClick(DialogInterface dialog, int which) {
   if (mCallback != null) {
     mNumberPicker.clearFocus();
     mCallback.onNumberSet(mDialogId, mNumberPicker.getValue());
     dialog.dismiss();
   }
 }
 /**
  * 数字ピッカーを初期化します。
  *
  * @param picker
  * @param min
  * @param max
  * @param step
  * @param format
  */
 private void setNumberPicker(NumberPicker picker, int min, int max, int step, int format) {
   picker.setMinValue(min / step - 1);
   picker.setMaxValue((max / step) - 1);
   String[] valueSet = new String[max / min];
   for (int i = min; i <= max; i += step) {
     valueSet[(i / step) - 1] = getString(format, i);
   }
   picker.setDisplayedValues(valueSet);
 }
  @Override
  protected void onRestoreInstanceState(Parcelable state) {
    SavedState savedState = (SavedState) state;
    super.onRestoreInstanceState(savedState.getSuperState());

    numberPicker1.setValue(savedState.getNumber1());
    numberPicker2.setValue(savedState.getNumber2());
    numberPicker3.setValue(savedState.getNumber3());
  }
  @Override
  protected void onBindDialogView(View view) {
    super.onBindDialogView(view);

    mNumberPicker = (NumberPicker) view.findViewById(R.id.number_picker);
    mNumberPicker.setMinValue(mMinValue);
    mNumberPicker.setMaxValue(mMaxValue);
    mNumberPicker.setValue(mValue);
  }
 @Override
 protected View onCreateDialogView() {
   mPicker = new NumberPicker(getContext());
   mPicker.setMinValue(1);
   mPicker.setMaxValue(100);
   // should be after setMinValue and setMaxValue calls
   mPicker.setValue(mNumber);
   return mPicker;
 }
Example #19
0
 @Override
 protected void onDialogClosed(boolean positiveResult) {
   if (positiveResult) {
     picker.clearFocus();
     int newValue = picker.getValue();
     if (callChangeListener(newValue)) {
       setValue(newValue);
     }
   }
 }
Example #20
0
 private void setDayShown(boolean shown) {
   if (shown) {
     toggleCalendar(false);
     mDaySpinner.setVisibility(VISIBLE);
     mDayEnabled = true;
   } else {
     mDaySpinner.setVisibility(GONE);
     mDayEnabled = false;
   }
 }
Example #21
0
 private void setMinuteShown(boolean shown) {
   if (shown) {
     mMinuteSpinner.setVisibility(VISIBLE);
     mTimeSpinners.findViewById(R.id.mincolon).setVisibility(VISIBLE);
     mMinuteEnabled = true;
   } else {
     mMinuteSpinner.setVisibility(GONE);
     mTimeSpinners.findViewById(R.id.mincolon).setVisibility(GONE);
     mMinuteEnabled = false;
   }
 }
Example #22
0
 private void setHourShown(boolean shown) {
   if (shown) {
     mHourSpinner.setVisibility(VISIBLE);
     mHourEnabled = true;
   } else {
     mHourSpinner.setVisibility(GONE);
     mAMPMSpinner.setVisibility(GONE);
     mTimeSpinners.setVisibility(GONE);
     mHourEnabled = false;
   }
 }
  @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 #24
0
 @Override
 public void onClick(View v) {
   SoundEffects.getInstance().playSound(SoundEffects.SOUND_CLICK);
   if (App.getMode() == App.MODE_CLASSICAL) {
     App.setLevel(np.getValue());
     // new CustomToast(getActivity(), np.getValue() + "");
     ((MainActivity) getActivity()).startGame();
   } else {
     App.setLevel(np.getValue());
     ((MainActivity) getActivity()).loadDifficultyFragment();
   }
 }
Example #25
0
 @Override
 public void setEnabled(boolean enabled) {
   if (mIsEnabled == enabled) {
     return;
   }
   super.setEnabled(enabled);
   mDaySpinner.setEnabled(enabled);
   mMonthSpinner.setEnabled(enabled);
   mYearSpinner.setEnabled(enabled);
   mCalendarView.setEnabled(enabled);
   mIsEnabled = enabled;
 }
Example #26
0
  private void updateSpinners() {
    updateDaySpinner();

    mYearToggle.setChecked(mHasYear);
    mYearToggle.setVisibility(mYearOptional ? View.VISIBLE : View.GONE);
    mYearPicker.setCurrent(mYear);
    mYearPicker.setVisibility(mHasYear ? View.VISIBLE : View.GONE);

    /* The month display uses 1-12 but our internal state stores it
     * 0-11 so add one when setting the display.
     */
    mMonthPicker.setCurrent(mMonth + 1);
  }
 private void notifyDateSet() {
   int hour = mHourSpinner.getValue();
   int minute = mMinuteSpinner.getValue();
   int sec = mSecSpinner.getValue();
   int milli = mMilliSpinner.getValue() * mStep + mBaseMilli;
   if (!mIs24hourFormat) {
     int ampm = mAmPmSpinner.getValue();
     if (hour == 12) {
       hour = 0;
     }
     hour += ampm * 12;
   }
   mListener.onTimeSet(hour, minute, sec, milli);
 }
Example #28
0
 private void updateDateControl() {
   /** 星期几算法 */
   Calendar cal = Calendar.getInstance();
   cal.setTimeInMillis(mDate.getTimeInMillis());
   cal.add(Calendar.DAY_OF_YEAR, -7 / 2 - 1);
   mDateSpinner.setDisplayedValues(null);
   for (int i = 0; i < 7; ++i) {
     cal.add(Calendar.DAY_OF_YEAR, 1);
     mDateDisplayValues[i] = (String) DateFormat.format("MM.dd EEEE", cal);
   }
   mDateSpinner.setDisplayedValues(mDateDisplayValues);
   mDateSpinner.setValue(7 / 2);
   mDateSpinner.invalidate();
 }
Example #29
0
 private void setPickedDate() {
   switch (userChoice) {
     case DAY:
     case WEEK:
       pickedCalendar =
           new GregorianCalendar(
               datePicker.getYear(), datePicker.getMonth(), datePicker.getDayOfMonth());
       break;
     case MONTH:
       pickedCalendar = new GregorianCalendar(yearPicker.getValue(), monthPicker.getValue(), 1);
       break;
     case YEAR:
       pickedCalendar = new GregorianCalendar(yearPicker.getValue(), 1, 1);
       break;
   }
 }
  public void addListenerOnNumberPickerCapacity() {

    txtNumberViewCapacity = (TextView) findViewById(R.id.numberView);
    NumberPicker numberPicker = (NumberPicker) findViewById(R.id.numberPicker);
    numberPicker.setMaxValue(MAX_VALUE);
    numberPicker.setMinValue(MIN_VALUE);
    numberPicker.setWrapSelectorWheel(true);
    numberPicker.setOnValueChangedListener(
        new NumberPicker.OnValueChangeListener() {
          @Override
          public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
            txtNumberViewCapacity.setText("Capacidade: " + newVal);
            capacity = newVal;
          }
        });
  }