예제 #1
0
  private void initNumberPicker(View view) {
    agePicker = (NumberPicker) view.findViewById(R.id.first_set_age_picker);
    heightPicker = (NumberPicker) view.findViewById(R.id.first_set_height_picker);
    weightPicker = (NumberPicker) view.findViewById(R.id.first_set_weight_picker);
    goalPicker = (NumberPicker) view.findViewById(R.id.first_set_goal_picker);

    agePicker.setDisplayedValues(dataManager.ages);
    heightPicker.setDisplayedValues(dataManager.heights);
    weightPicker.setDisplayedValues(dataManager.weights);
    goalPicker.setDisplayedValues(dataManager.goals);

    agePicker.setMinValue(0);
    agePicker.setMaxValue(60);
    agePicker.setValue(dataManager.getSelfData(DataManager.AGE));

    heightPicker.setMinValue(0);
    heightPicker.setMaxValue(dataManager.heights.length - 1);
    heightPicker.setValue(dataManager.getSelfData(DataManager.HEIGHT));

    weightPicker.setMinValue(0);
    weightPicker.setMaxValue(dataManager.weights.length - 1);
    weightPicker.setValue(dataManager.getSelfData(DataManager.WEIGHT));

    goalPicker.setMinValue(0);
    goalPicker.setMaxValue(dataManager.goals.length - 1);
    goalPicker.setValue(dataManager.getSelfData(DataManager.GOAL));
  }
예제 #2
0
  private void np_initiate() {
    // TODO Auto-generated method stub
    np_T1 = (NumberPicker) findViewById(R.id.np_T1);
    String[] nums = new String[11];
    for (int i = 0; i < nums.length; i++) nums[i] = Integer.toString(i);

    np_T1.setMinValue(0);
    np_T1.setMaxValue(10);
    np_T1.setWrapSelectorWheel(false);
    np_T1.setDisplayedValues(nums);
    np_T1.setValue(0);

    np_T2 = (NumberPicker) findViewById(R.id.np_T2);

    np_T2.setMinValue(0);
    np_T2.setMaxValue(10);
    np_T2.setWrapSelectorWheel(false);
    np_T2.setDisplayedValues(nums);
    np_T2.setValue(0);

    np_T3 = (NumberPicker) findViewById(R.id.np_T3);

    np_T3.setMinValue(0);
    np_T3.setMaxValue(10);
    np_T3.setWrapSelectorWheel(false);
    np_T3.setDisplayedValues(nums);
    np_T3.setValue(0);
  }
  @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());
  }
예제 #4
0
  void updateSpinners() {
    if (mDayEnabled) {
      if (mCurrentDate.equals(mMinDate)) {
        mDaySpinner.setMinValue(mCurrentDate.get(Calendar.DAY_OF_MONTH));
        mDaySpinner.setMaxValue(mCurrentDate.getActualMaximum(Calendar.DAY_OF_MONTH));
      } else if (mCurrentDate.equals(mMaxDate)) {
        mDaySpinner.setMinValue(mCurrentDate.getActualMinimum(Calendar.DAY_OF_MONTH));
        mDaySpinner.setMaxValue(mCurrentDate.get(Calendar.DAY_OF_MONTH));
      } else {
        mDaySpinner.setMinValue(1);
        mDaySpinner.setMaxValue(mCurrentDate.getActualMaximum(Calendar.DAY_OF_MONTH));
      }
      mDaySpinner.setValue(mCurrentDate.get(Calendar.DAY_OF_MONTH));
    }

    if (mWeekEnabled) {
      mWeekSpinner.setMinValue(1);
      mWeekSpinner.setMaxValue(mCurrentDate.getActualMaximum(Calendar.WEEK_OF_YEAR));
      mWeekSpinner.setValue(mCurrentDate.get(Calendar.WEEK_OF_YEAR));
    }

    if (mMonthEnabled) {
      mMonthSpinner.setDisplayedValues(null);
      if (mCurrentDate.equals(mMinDate)) {
        mMonthSpinner.setMinValue(mCurrentDate.get(Calendar.MONTH));
        mMonthSpinner.setMaxValue(mCurrentDate.getActualMaximum(Calendar.MONTH));
      } else if (mCurrentDate.equals(mMaxDate)) {
        mMonthSpinner.setMinValue(mCurrentDate.getActualMinimum(Calendar.MONTH));
        mMonthSpinner.setMaxValue(mCurrentDate.get(Calendar.MONTH));
      } else {
        mMonthSpinner.setMinValue(Calendar.JANUARY);
        mMonthSpinner.setMaxValue(Calendar.DECEMBER);
      }

      String[] displayedValues =
          Arrays.copyOfRange(
              mShortMonths, mMonthSpinner.getMinValue(), mMonthSpinner.getMaxValue() + 1);
      mMonthSpinner.setDisplayedValues(displayedValues);
      mMonthSpinner.setValue(mCurrentDate.get(Calendar.MONTH));
    }

    if (mYearEnabled) {
      mYearSpinner.setMinValue(mMinDate.get(Calendar.YEAR));
      mYearSpinner.setMaxValue(mMaxDate.get(Calendar.YEAR));
      mYearSpinner.setValue(mCurrentDate.get(Calendar.YEAR));
    }

    if (mHourEnabled) {
      if (mIs12HourMode) {
        mHourSpinner.setValue(mCurrentDate.get(Calendar.HOUR));
        mAMPMSpinner.setValue(mCurrentDate.get(Calendar.AM_PM));
        mAMPMSpinner.setDisplayedValues(mShortAMPMs);
      } else {
        mHourSpinner.setValue(mCurrentDate.get(Calendar.HOUR_OF_DAY));
      }
    }
    if (mMinuteEnabled) {
      mMinuteSpinner.setValue(mCurrentDate.get(Calendar.MINUTE));
    }
  }
 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);
 }
예제 #6
0
  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)));
    }
  }
  /**
   * @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);
  }
예제 #8
0
  @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;
  }
  @Nullable
  @Override
  public View onCreateView(
      LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

    final PersistenceManager persistenceManager = PersistenceManager.getInstance(getContext());

    View fragmentView = View.inflate(getContext(), R.layout.fragment_widget_update_interval, null);
    NumberPicker picker = (NumberPicker) fragmentView.findViewById(R.id.picker_dialog_widget_time);
    picker.setMinValue(0);
    picker.setMaxValue(GeneralHelper.WIDGET_UPDATE_HOUR_INTERVALS.length - 1);
    picker.setValue(persistenceManager.getWidgetPickerValue());
    picker.setDisplayedValues(GeneralHelper.getWidgetPickerDisplayedValues());
    picker.setOnValueChangedListener(
        new NumberPicker.OnValueChangeListener() {
          @Override
          public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
            persistenceManager.setWidgetPickerValue(newVal);
            setAlarmForWidgetUpdate(
                getContext(), GeneralHelper.getMillisForWidgetDisplayedValue(newVal));
          }
        });

    return fragmentView;
  }
예제 #10
0
  /*년도 최대값을 올해로 설정하게, 캘린더로 현재 연도 가져오기.*/
  public void birthDialog() {
    final Dialog d = new Dialog(BabyAddActivity.this);
    d.setTitle("생년월일");
    d.setContentView(R.layout.dialog_baby_add_birth);
    //                아마도 가로세로 크기 지정???????????????????????????????????
    //        d.getWindow().setLayout(디멘으로 값지정);

    final NumberPicker npY, npM, npD;

    npY = (NumberPicker) d.findViewById(R.id.numberPickerY);
    npY.setMaxValue(2015);
    npY.setMinValue(1900);
    npY.setValue(2000);
    npY.setWrapSelectorWheel(false);

    npM = (NumberPicker) d.findViewById(R.id.numberPickerM);
    npM.setMaxValue(12);
    npM.setMinValue(1);
    npM.setWrapSelectorWheel(false);

    npD = (NumberPicker) d.findViewById(R.id.numberPickerD);
    npD.setMaxValue(31);
    npD.setMinValue(1);
    npD.setWrapSelectorWheel(false);

    Button btn_ok;
    btn_ok = (Button) d.findViewById(R.id.btn_birth_ok);
    btn_ok.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            // 한자리수 월 일 앞에 0 붙이기
            StringBuilder sb = new StringBuilder();
            String Y, M, D;
            Y = npY.getValue() + "";
            M = npM.getValue() + "";
            D = npD.getValue() + "";
            if (String.valueOf(npM.getValue()).length() == 1) {
              M = "0" + npM.getValue();
            }
            if (String.valueOf(npD.getValue()).length() == 1) {
              D = "0" + npD.getValue();
            }
            sb.append(Y);
            sb.append(M);
            sb.append(D);
            babyBirth_num = sb.toString(); // 서버로 보내는 값
            babyBirth.setText(
                String.valueOf(npY.getValue())
                    + " / "
                    + String.valueOf(npM.getValue())
                    + " / "
                    + String.valueOf(npD.getValue()));
            d.dismiss();
          }
        });

    d.show();
  }
예제 #11
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 View onCreateDialogView() {
   mPicker = new NumberPicker(getContext());
   mPicker.setMinValue(1);
   mPicker.setMaxValue(100);
   // should be after setMinValue and setMaxValue calls
   mPicker.setValue(mNumber);
   return mPicker;
 }
  @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);
  }
  private void loadUserHeight() {
    if (null != user.getHeight()) {
      String height[] = user.getHeight().split("-");
      heightFeet = Integer.parseInt(height[0]);
      heightInch = Integer.parseInt(height[1]);
    } else {
      heightFeet = Globals.DEFAULT_HEIGHT_FEET;
      heightInch = Globals.DEFAULT_HEIGHT_INCH;
    }

    pickerHeightFeet.setMinValue(Globals.MIN_HEIGHT_FEET);
    pickerHeightFeet.setMaxValue(Globals.MAX_HEIGHT_FEET);
    pickerHeightFeet.setValue(heightFeet);
    pickerHeightFeet.setWrapSelectorWheel(false);

    pickerHeightFeet.setOnValueChangedListener(
        new NumberPicker.OnValueChangeListener() {

          @Override
          public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
            isDataChanged = true;
            Log.v(
                Globals.TAG,
                "picker : " + picker + ", oldVal : " + oldVal + ", newVal : " + newVal);
          }
        });

    pickerHeightInch.setMinValue(Globals.MIN_HEIGHT_INCH);
    pickerHeightInch.setMaxValue(Globals.MAX_HEIGHT_INCH);
    pickerHeightInch.setValue(heightInch);
    pickerHeightInch.setWrapSelectorWheel(false);

    pickerHeightInch.setOnValueChangedListener(
        new NumberPicker.OnValueChangeListener() {

          @Override
          public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
            isDataChanged = true;
            Log.v(
                Globals.TAG,
                "picker : " + picker + ", oldVal : " + oldVal + ", newVal : " + newVal);
          }
        });
  }
예제 #15
0
  public DateTimePicker(Context context) {
    super(context);
    /*
     *獲取系統時間
     */
    mDate = Calendar.getInstance();
    mHour = mDate.get(Calendar.HOUR_OF_DAY);
    mMinute = mDate.get(Calendar.MINUTE);
    /** 加载布局 */
    inflate(context, R.layout.datadialog, this);
    /** 初始化控件 */
    mDateSpinner = (NumberPicker) this.findViewById(R.id.np_date);
    mDateSpinner.setMinValue(0);
    mDateSpinner.setMaxValue(6);
    updateDateControl();
    mDateSpinner.setOnValueChangedListener(mOnDateChangedListener);
    mHourSpinner = (NumberPicker) this.findViewById(R.id.np_hour);
    mHourSpinner.setMaxValue(23);
    mHourSpinner.setMinValue(0);
    mHourSpinner.setValue(mHour);
    mHourSpinner.setOnValueChangedListener(mOnHourChangedListener);
    mHourSpinner.setDescendantFocusability(FOCUS_BLOCK_DESCENDANTS);

    mMinuteSpinner = (NumberPicker) this.findViewById(R.id.np_minute);
    mMinuteSpinner.setMaxValue(59);
    mMinuteSpinner.setMinValue(0);
    mMinuteSpinner.setValue(mMinute);
    mMinuteSpinner.setOnValueChangedListener(mOnMinuteChangedListener);
    mMinuteSpinner.setDescendantFocusability(FOCUS_BLOCK_DESCENDANTS);
    mMinuteSpinner.setWrapSelectorWheel(true);

    FixScroller mScroller =
        new FixScroller(mDateSpinner.getContext(), new DecelerateInterpolator());
    BaseUtil.setViewPagerScroller(mDateSpinner, mScroller);

    FixScroller mScroller1 =
        new FixScroller(mHourSpinner.getContext(), new DecelerateInterpolator());
    BaseUtil.setViewPagerScroller(mHourSpinner, mScroller1);

    FixScroller mScroller2 =
        new FixScroller(mMinuteSpinner.getContext(), new DecelerateInterpolator());
    BaseUtil.setViewPagerScroller(mMinuteSpinner, mScroller2);
  }
예제 #16
0
  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();
          }
        });
  }
예제 #17
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fragment_edit_exercise);

    openDB();
    btnUpdateExercise();
    btnStart();
    NumberPicker npSets = (NumberPicker) findViewById(R.id.npSetsForExercise);
    NumberPicker npReps = (NumberPicker) findViewById(R.id.npRepsForExercise);
    npSets.setMaxValue(100);
    npSets.setMinValue(0);
    npSets.setValue(fromExerciseActivity.ReturnSets());
    // npSets.setValue(reps);
    npReps.setMaxValue(100);
    npReps.setMinValue(0);
    npReps.setValue(fromExerciseActivity.ReturnReps());
    TextView txtNameOfExercise = (TextView) findViewById(R.id.txtNameOfExercise);
    txtNameOfExercise.setText(fromExerciseActivity.exerciseNamexercise);
  }
  @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);
  }
 @Override
 protected void showDialog(Bundle state) {
   super.showDialog(state);
   User user = ((CompassApplication) getContext().getApplicationContext()).getUser();
   mValue = user.getDailyNotifications();
   Dialog dialog = getDialog();
   NumberPicker picker = (NumberPicker) dialog.findViewById(R.id.number_picker_picker);
   picker.setOnValueChangedListener(this);
   picker.setMinValue(0);
   picker.setMaxValue(20);
   picker.setValue(mValue);
   picker.setWrapSelectorWheel(false);
 }
예제 #20
0
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    LayoutInflater inflater = getActivity().getLayoutInflater();
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    View view = inflater.inflate(R.layout.dialog_score_picker_layout, null);

    NumberPicker homeScorePicker = (NumberPicker) view.findViewById(R.id.number_score_picker_home);
    NumberPicker awayScorePicker = (NumberPicker) view.findViewById(R.id.number_score_picker_away);

    homeScorePicker.setMinValue(0);
    homeScorePicker.setMaxValue(20);
    homeScorePicker.setValue(homeScore);
    awayScorePicker.setMinValue(0);
    awayScorePicker.setMaxValue(20);
    awayScorePicker.setValue(awayScore);

    builder
        .setView(view)
        .setPositiveButton(
            R.string.action_confirm,
            new DialogInterface.OnClickListener() {

              @Override
              public void onClick(DialogInterface dialog, int which) {
                listener.onPositiveClick(ScorePicker.this);
              }
            })
        .setNegativeButton(
            R.string.cancel,
            new DialogInterface.OnClickListener() {

              @Override
              public void onClick(DialogInterface dialog, int which) {
                listener.onNegativeClick(ScorePicker.this);
              }
            });

    return builder.create();
  }
예제 #21
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();
 }
 @Override
 public void onClick(DialogInterface dialog, int which) {
   switch (which) {
     case AlertDialog.BUTTON_POSITIVE:
       lastChosenDelay = newChosenDelay;
       if (listener != null) {
         listener.onDelayChosen(mNumberPicker.getValue());
       }
       dismiss();
       break;
     case AlertDialog.BUTTON_NEGATIVE:
       mNumberPicker.setValue(lastChosenDelay);
       dismiss();
       break;
   }
 }
예제 #23
0
 public void donateButtonPressed(View view) {
   String method = paymentMethod.getCheckedRadioButtonId() == R.id.PayPal ? "PayPal" : "Direct";
   int donatedAmount = amountPicker.getValue();
   if (donatedAmount == 0) {
     String text = amountText.getText().toString();
     if (!text.equals("")) donatedAmount = Integer.parseInt(text);
   }
   if (donatedAmount > 0) {
     app.newDonation(new Donation(donatedAmount, method));
     progressBar.setProgress(app.totalDonated);
     String totalDonatedStr = "$" + app.totalDonated;
     amountTotal.setText(totalDonatedStr);
   }
   amountText.setText("");
   amountPicker.setValue(0);
 }
예제 #24
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tip);

    np = (NumberPicker) findViewById(R.id.tip_numberPicker);
    np.setMaxValue(9);
    np.setMinValue(0);
    np.setValue(5);

    TextView t = (TextView) findViewById(R.id.tip_text);
    // t.setText("Tip the tour creator!");

    //        Button b = (Button) findViewById(R.id.tip_button);

  }
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    type = SET_SELECTION;
    prev = getArguments().getInt(Constants.TOTAL_PLAYERS_KEY, 8);
    next = Integer.MAX_VALUE;

    final Dialog dialog = new Dialog(getActivity(), AlertDialog.THEME_HOLO_LIGHT);
    dialog.setTitle("Select Number of Total Players");
    dialog.setContentView(R.layout.dialog_number_picker);
    Button negative = (Button) dialog.findViewById(R.id.game_setup_dialog_negativebutton);
    Button positive = (Button) dialog.findViewById(R.id.game_setup_dialog_positivebutton);

    NumberPicker picker = (NumberPicker) dialog.findViewById(R.id.game_setup_dialog_numberpicker);

    picker.setMaxValue(10);
    picker.setMinValue(5);
    picker.setValue(prev);

    picker.setWrapSelectorWheel(false);
    picker.setOnValueChangedListener(this);
    picker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);

    negative.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            dialog.dismiss();
          }
        });

    positive.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            if (prev > next) type = CLEAR_SELECTION;

            if (next == Integer.MAX_VALUE) next = prev;

            getPlotListener().onEventStart(type, next);

            dialog.dismiss();
          }
        });

    return dialog;
  }
 @Override
 public Dialog onCreateDialog(Bundle savedInstanceState) {
   AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
   builder.setPositiveButton(getString(R.string.ok), this);
   builder.setNegativeButton(getString(R.string.cancel), this);
   builder.setTitle(getString(R.string.choose_seconds_delay));
   AlertDialog dialog = builder.create();
   View v =
       LayoutInflater.from(getActivity()).inflate(R.layout.delay_picker_fragment_layout, null);
   dialog.setView(v);
   mNumberPicker = (NumberPicker) v.findViewById(R.id.number_picker);
   mNumberPicker.setMinValue(1);
   mNumberPicker.setMaxValue(60);
   lastChosenDelay = getArguments().getInt(DEF_VALUE_TAG);
   if (lastChosenDelay == -1) {
     lastChosenDelay = 3;
   }
   mNumberPicker.setValue(lastChosenDelay);
   return dialog;
 }
  @Override
  protected void onPrepareDialogBuilder(final Builder builder) {
    super.onPrepareDialogBuilder(builder);

    mNumberPicker = new NumberPicker(this.getContext());
    mNumberPicker.setMinValue(mMinValue);
    mNumberPicker.setMaxValue(mMaxValue);
    mNumberPicker.setValue(mSelectedValue);
    mNumberPicker.setWrapSelectorWheel(mWrapSelectorWheel);
    mNumberPicker.setLayoutParams(
        new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    final LinearLayout linearLayout = new LinearLayout(this.getContext());
    linearLayout.setLayoutParams(
        new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    linearLayout.setGravity(Gravity.CENTER);
    linearLayout.addView(mNumberPicker);

    builder.setView(linearLayout);
  }
 private void initPicker(NumberPicker picker, int currentValue) {
   picker.setMinValue(1);
   picker.setMaxValue(25);
   picker.setValue(currentValue);
   picker.setFormatter(
       new NumberPicker.Formatter() {
         @Override
         public String format(int value) {
           return String.format("第%1$d周", value);
         }
       });
   picker.setOnValueChangedListener(
       new NumberPicker.OnValueChangeListener() {
         @Override
         public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
           weekResultTv.setText(
               String.format(
                   WEEK_RESULT_FORMAT, startWeekPicker.getValue(), endWeekPicker.getValue()));
         }
       });
 }
  private void loadUserWeight() {
    weightLbs = user.getWeightLbs();
    if (weightLbs <= 0) {
      weightLbs = Globals.DEFAULT_WEIGHT_LBS;
    }

    pickerWeight.setMinValue(Globals.MIN_WEIGHT_LBS);
    pickerWeight.setMaxValue(Globals.MAX_WEIGHT_LBS);
    pickerWeight.setValue(weightLbs);
    pickerWeight.setWrapSelectorWheel(false);

    pickerWeight.setOnValueChangedListener(
        new NumberPicker.OnValueChangeListener() {

          @Override
          public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
            isDataChanged = true;
            Log.v(
                Globals.TAG,
                "picker : " + picker + ", oldVal : " + oldVal + ", newVal : " + newVal);
          }
        });
  }
예제 #30
0
  /**
   * 起動時のイベント処理
   *
   * @param savedInstanceState
   */
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_start_meal);

    // 効果音の準備をします。
    player = MealSoundPlayer.getInstance();
    player.loadSound(getApplicationContext());

    // 食べ物画像の準備をします。
    loadImage();
    setTouchImageListener();

    // タイマー時刻の初期化
    mTimePicker = (NumberPicker) findViewById(R.id.numberPicker);
    setNumberPicker(mTimePicker, 5, 60, 5, R.string.timeFormat);

    // 初期値は20分に設定
    mTimePicker.setValue(3);

    // キーボードは非表示にする
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
  }