Esempio n. 1
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);
  }
Esempio n. 2
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));
  }
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View view = inflater.inflate(R.layout.picker, null);

    final NumberPicker npDays = (NumberPicker) view.findViewById(R.id.npDays);
    npDays.setMaxValue(30);
    npDays.setMinValue(0);

    final NumberPicker npHours = (NumberPicker) view.findViewById(R.id.npHours);
    npHours.setMaxValue(24);
    npHours.setMinValue(0);

    builder
        .setView(view)
        .setTitle("Remind Me: ")
        // Add action buttons
        .setPositiveButton(
            "Ok",
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int id) {

                AddCourseItem.remindDays = npDays.getValue();
                AddCourseItem.remindHours = npHours.getValue();

                setReminderLable();
              }

              private void setReminderLable() {
                if (AddCourseItem.remindDays == 0 && AddCourseItem.remindHours == 0) {
                  tvRemindMeTime.setText("0 Day(s) 0 Hour(s) Before");
                } else if (AddCourseItem.remindDays > 0 && AddCourseItem.remindHours > 0) {
                  tvRemindMeTime.setText(
                      AddCourseItem.remindDays
                          + " Day(s) "
                          + AddCourseItem.remindHours
                          + "Hour(s) Before");

                } else if (AddCourseItem.remindDays > 0) {
                  tvRemindMeTime.setText(AddCourseItem.remindDays + " Day(s) Before");

                } else if (AddCourseItem.remindHours > 0) {
                  tvRemindMeTime.setText(AddCourseItem.remindHours + " Hour(s) Before");
                }
              }
            })
        .setNegativeButton(
            "Cancel",
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int id) {
                // TODO
              }
            });

    return builder.create();
  }
Esempio n. 4
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();
  }
Esempio n. 5
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));
    }
  }
  private void loadViews() {
    LayoutInflater.from(getContext()).inflate(R.layout.lock_combination_picker, this, true);

    numberPicker1 = (NumberPicker) findViewById(R.id.number1);
    numberPicker1.setMinValue(0);
    numberPicker1.setMaxValue(10);

    numberPicker2 = (NumberPicker) findViewById(R.id.number2);
    numberPicker2.setMinValue(0);
    numberPicker2.setMaxValue(10);

    numberPicker3 = (NumberPicker) findViewById(R.id.number3);
    numberPicker3.setMinValue(0);
    numberPicker3.setMaxValue(10);
  }
  /**
   * @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);
  }
Esempio n. 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;
  }
  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();
  }
  @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;
  }
 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);
 }
Esempio n. 12
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;
 }
Esempio n. 13
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());
 }
Esempio n. 14
0
 /**
  * 数字ピッカーを初期化します。
  *
  * @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 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);
          }
        });
  }
Esempio n. 18
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);
  }
Esempio n. 19
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();
          }
        });
  }
Esempio n. 20
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);
  }
Esempio n. 22
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();
  }
 @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);
 }
Esempio n. 24
0
  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;
          }
        });
  }
Esempio n. 25
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)));
    }
  }
Esempio n. 26
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;
  }
Esempio n. 28
0
  @Nullable
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_level, container, false);
    np = (NumberPicker) v.findViewById(R.id.picker);
    heading = (CTextView) v.findViewById(R.id.level_moves);

    heading.setText("Select Level and Press Continue");

    np.setMinValue(4);
    np.setMaxValue(9);
    np.setOnScrollListener(this);

    FlatButton fb = (FlatButton) v.findViewById(R.id.level_ok);
    fb.setOnClickListener(this);
    return v;
  }
Esempio n. 29
0
  private void init() {

    // Holds all BoardItems
    Settings.allBoardItems = new ArrayList<BoardItem>();
    // Holds all Players
    Settings.allPlayers = new ArrayList<Player>();

    Settings.colors = new ArrayList<String>();
    Settings.colors.add("Farbe wählen");
    Settings.colors.add("Schwarz");
    Settings.colors.add("Grün");
    Settings.colors.add("Blau");
    Settings.colors.add("Rot");
    Settings.colors.add("Violett");
    Settings.colors.add("Grau");
    Settings.colors.add("Gelb");
    Settings.colors.add("Pink");
    Settings.colors.add("Orange");

    // TODO Auto-generated method stub
    playerPicker = (NumberPicker) findViewById(R.id.main_how_many_player_picker);

    playerPicker.setMinValue(MIN_PLAYERS);
    playerPicker.setMaxValue(MAX_PLAYERS);
    playerPicker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);

    mainNext = (Button) findViewById(R.id.main_next);

    mainNext.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            Settings.numberOfPlayers = playerPicker.getValue();
            String text =
                String.format(
                    getResources().getString(R.string.player_x), Settings.numberOfPlayers);
            System.out.println("numPlayers: " + Settings.numberOfPlayers + "; " + text);
            startActivity(new Intent(getApplicationContext(), PlayerSettings.class));
          }
        });
  }
  @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);
  }