Java Code Examples for android.widget.NumberPicker

The following are top voted examples for showing how to use android.widget.NumberPicker. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: GitHub   File: CustomTileDimensions.java   View source code 7 votes vote down vote up
@OnClick(R.id.custom_tile_height_size)
public void onHeightClick() {
  final NumberPicker view = new NumberPicker(this);
  view.setMinValue(24);
  view.setMaxValue(64);
  view.setWrapSelectorWheel(false);
  view.setValue(currentTileHeight);
  new AlertDialog.Builder(this)
          .setView(view)
          .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(@NonNull DialogInterface dialog, int which) {
              currentTileHeight = view.getValue();
              widget.setTileHeightDp(currentTileHeight);
            }
          })
          .show();
}
 
Example 2
Project: HighSchoolScienceBowlPractice-Android   File: StudyModeSettingsPage.java   View source code 7 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_study_mode_settings_page);

    biologyButton = (ToggleButton) findViewById(R.id.biologyButton);
    chemistryButton = (ToggleButton) findViewById(R.id.chemistryButton);
    earthAndSpaceButton = (ToggleButton) findViewById(R.id.earthAndSpaceButton);
    energyButton = (ToggleButton) findViewById(R.id.energyButton);
    mathButton = (ToggleButton) findViewById(R.id.mathButton);
    physicsButton = (ToggleButton) findViewById(R.id.physicsButton);
    randomButton = (ToggleButton) findViewById(R.id.randomButton);

    roundNumPicker = (NumberPicker) findViewById(R.id.roundNumPicker);
    roundNumPicker.setMinValue(0);
    roundNumPicker.setMaxValue(roundOptions.length-1);
    roundNumPicker.setWrapSelectorWheel(false);
    roundNumPicker.setDisplayedValues(roundOptions);

    menuButton = (Button) findViewById(R.id.menuButton);
}
 
Example 3
Project: CatchSpy   File: GlobalSettingsFragment.java   View source code 6 votes vote down vote up
@SuppressWarnings("SameParameterValue")
private void playerNumberAlert(String title, final String preferenceName, int min, int max, int default_num) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    LayoutInflater inflater = LayoutInflater.from(getActivity());
    View mView = inflater.inflate(R.layout.dialog_number_picker, (ViewGroup) getActivity().findViewById(R.id.dialog_layout_number_picker));
    final NumberPicker numberPicker = mView.findViewById(R.id.dialog_number_picker);
    numberPicker.setMinValue(min);
    numberPicker.setMaxValue(max);
    numberPicker.setValue(default_num);
    builder.setTitle(title);
    builder.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            sharedPreferences.edit().putInt(preferenceName, numberPicker.getValue()).apply();
        }
    });
    builder.setNegativeButton(android.R.string.no, null);
    builder.setView(mView);
    builder.show();
}
 
Example 4
Project: GitHub   File: CustomTileDimensions.java   View source code 6 votes vote down vote up
@OnClick(R.id.custom_tile_width_size)
public void onWidthClick() {
  final NumberPicker view = new NumberPicker(this);
  view.setMinValue(24);
  view.setMaxValue(64);
  view.setWrapSelectorWheel(false);
  view.setValue(currentTileWidth);
  new AlertDialog.Builder(this)
          .setView(view)
          .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(@NonNull DialogInterface dialog, int which) {
              currentTileWidth = view.getValue();
              widget.setTileWidthDp(currentTileWidth);
            }
          })
          .show();
}
 
Example 5
Project: GitHub   File: DynamicSettersActivity.java   View source code 6 votes vote down vote up
@OnClick(R.id.button_set_tile_size)
void onTileSizeClicked() {
    final NumberPicker view = new NumberPicker(this);
    view.setMinValue(24);
    view.setMaxValue(64);
    view.setWrapSelectorWheel(false);
    view.setValue(currentTileSize);
    new AlertDialog.Builder(this)
            .setView(view)
            .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(@NonNull DialogInterface dialog, int which) {
                    currentTileSize = view.getValue();
                    widget.setTileSizeDp(currentTileSize);
                }
            })
            .show();
}
 
Example 6
Project: HustEating   File: SettingFragment.java   View source code 6 votes vote down vote up
/**
 * 初始化传入的moneyPicker
 *
 * @param numberPickerArrayList 需要初始化的NumPicker
 */
private void initNumPicker(ArrayList<NumberPicker> numberPickerArrayList) {
    Iterator iterator = numberPickerArrayList.iterator();
    while (iterator.hasNext()) {
        NumberPicker moneyPicker = (NumberPicker) iterator.next();
        moneyPicker.setFormatter(this);
        moneyPicker.setOnValueChangedListener(this);
        moneyPicker.setOnScrollListener(this);
        moneyPicker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
    }

    numberPickerArrayList.get(0).setMinValue(3);numberPickerArrayList.get(0).setMaxValue(15);//早餐的价格区间
    numberPickerArrayList.get(1).setMinValue(5);numberPickerArrayList.get(1).setMaxValue(30);//午餐的价格区间
    numberPickerArrayList.get(2).setMinValue(5);numberPickerArrayList.get(2).setMaxValue(30);//晚餐的价格区间


    numberPickerArrayList.get(0).setValue(preferences.getInt("moneyBreakfastChosen", 5));//早餐默认为5
    numberPickerArrayList.get(1).setValue(preferences.getInt("moneyLunchChosen", 10));//午饭默认为10
    numberPickerArrayList.get(2).setValue(preferences.getInt("moneyDinnerChosen", 12));//早餐默认为12

}
 
Example 7
Project: LiveNotes   File: KeySigDialogFragment.java   View source code 6 votes vote down vote up
private void initializeViews(Dialog dialog) {
    major = (ToggleButton) dialog.findViewById(R.id.major);
    minor = (ToggleButton) dialog.findViewById(R.id.minor);
    dialog.findViewById(R.id.major_parent).setOnClickListener(__ -> onMajorClicked());
    dialog.findViewById(R.id.minor_parent).setOnClickListener(__ -> onMinorClicked());

    keySigImage = (ImageView) dialog.findViewById(R.id.key_sig_image);

    key = (NumberPicker) dialog.findViewById(R.id.key);
    key.setWrapSelectorWheel(false);
    key.setMinValue(0);
    key.setMaxValue(KeySigHandler.FIFTHS.length - 1);

    major.setChecked(false);
    onMajorClicked();
    key.setOnValueChangedListener(this);
    key.setValue(6);
}
 
Example 8
Project: orgzly-android   File: EspressoUtils.java   View source code 6 votes vote down vote up
/**
 * Set value for {@link NumberPicker}
 */
public static ViewAction setNumber(final int n) {
    return new ViewAction() {
        @Override
        public void perform(UiController uiController, View view) {
            ((NumberPicker) view).setValue(n);
        }

        @Override
        public String getDescription() {
            return "Set NumberPicker value";
        }

        @Override
        public Matcher<View> getConstraints() {
            return ViewMatchers.isAssignableFrom(NumberPicker.class);
        }
    };
}
 
Example 9
Project: what_are_those_app   File: AgeScreen.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_age);
    final EditText ageEdit = (EditText) findViewById(R.id.age);

    ageEdit.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) {
                hideKeyboard(v);
                ageEdit.setCursorVisible(false);
            } else {
                showKeyboard(v);
                ageEdit.setCursorVisible(true);
            }
        }
    });

    NumberPicker numberPicker = (NumberPicker) findViewById(R.id.numberPicker);
    numberPicker.setMaxValue(28);
    numberPicker.setMinValue(1);

    NumberPicker stringPicker = (NumberPicker) findViewById(R.id.stringPicker);
    stringPicker.setMaxValue(2);
    stringPicker.setMinValue(0);
    stringPicker.setDisplayedValues( new String[] { "Days", "Months", "Years" } );

}
 
Example 10
Project: OneTwo   File: ListAdapter.java   View source code 6 votes vote down vote up
public ListAdapterViewHolder(View view) {
    super(view);
    mTextView = (TextView) view.findViewById(R.id.tv_object_data);
    removeButton = (Button) view.findViewById(R.id.remove_button);
    numberPicker = (NumberPicker) view.findViewById(R.id.number_picker);
    numberPicker.setMaxValue(99999);
    numberPicker.setMinValue(0);
    numberPicker.setOnScrollListener(this);
    numberPicker.setOnValueChangedListener(this);
    numberPicker.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            v.performClick();
            return true;
        }
    });
    view.setOnClickListener(this);
}
 
Example 11
Project: HighSchoolScienceBowlPractice-Android   File: ReaderModeSettingsPage.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_reader_mode_settings_page);

    setNumPicker = (NumberPicker) findViewById(R.id.setNumPicker);
    setNumPicker.setMinValue(0);
    setNumPicker.setMaxValue(setOptions.length-1);
    setNumPicker.setWrapSelectorWheel(false);
    setNumPicker.setDisplayedValues(setOptions);

    roundNumPicker = (NumberPicker) findViewById(R.id.roundNumPicker);
    roundNumPicker.setMinValue(0);
    roundNumPicker.setMaxValue(roundOptions.length-1);
    roundNumPicker.setWrapSelectorWheel(false);
    roundNumPicker.setDisplayedValues(roundOptions);

    tossupTimeSpinner = (Spinner) findViewById(R.id.tossupTimeSelector);
    bonusTimeSpinner = (Spinner) findViewById(R.id.bonusTimeSelector);

    menuButton = (Button) findViewById(R.id.menuButton);
}
 
Example 12
Project: FitterNumberPicker   File: MainActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle(R.string.app_name);

    NumberPicker stockNumberPicker = (NumberPicker) findViewById(R.id.stock);
    stockNumberPicker.setMinValue(0);
    stockNumberPicker.setMaxValue(10);

    FitterNumberPicker defaultNumberPicker = (FitterNumberPicker) findViewById(R.id.default_number_picker);
    FitterNumberPicker customNumberPicker = (FitterNumberPicker) findViewById(R.id.custom_number_picker);

    ViewConfiguration configuration = ViewConfiguration.get(this);
    //This would be a good value to start with, then / or * to adjust
    //By default, the velocity is divided by 8, so do what you want to adjust
    int maxFlingVelocity = configuration.getScaledMaximumFlingVelocity() / 6;
    customNumberPicker.setMaximumFlingVelocity(maxFlingVelocity);
}
 
Example 13
Project: FitterNumberPicker   File: FitterNumberPicker.java   View source code 6 votes vote down vote up
/**
 * Uses reflection to access divider private attribute and override its color
 * Use Color.Transparent if you wish to hide them
 *
 * @return true if separator set, false if field was not accessible
 */
public boolean setSeparatorColor(int separatorColor) {
    this.separatorColor = separatorColor;
    if (fieldPickerDivider == null) {
        Field[] pickerFields = NumberPicker.class.getDeclaredFields();
        for (Field pf : pickerFields) {
            if (pf.getName().equals("mSelectionDivider")) {
                pf.setAccessible(true);
                fieldPickerDivider = pf;
                break;
            }
        }
    }
    if (fieldPickerDivider != null) {
        try {
            fieldPickerDivider.set(this, new ColorDrawable(separatorColor));
        } catch (IllegalAccessException | IllegalArgumentException e) {
            return false;
        }
    } else {
        return false;
    }
    return true;
}
 
Example 14
Project: FitterNumberPicker   File: FitterNumberPicker.java   View source code 6 votes vote down vote up
private boolean updateSelectorWheelPaint() {
    if (selectorWheelPaint == null) {
        try {
            Field selectorWheelPaintField = NumberPicker.class.getDeclaredField("mSelectorWheelPaint");
            selectorWheelPaintField.setAccessible(true);

            selectorWheelPaint = ((Paint) selectorWheelPaintField.get(this));
        } catch (Exception e) {
            return false;
        }
    }
    if (selectorWheelPaint != null) {
        selectorWheelPaint.setColor(textColor);
        selectorWheelPaint.setTextSize(textSize);
        invalidate();
        return true;
    }
    return false;
}
 
Example 15
Project: aos-Video   File: SubtitleDelayTVPicker.java   View source code 6 votes vote down vote up
public SubtitleDelayTVPicker(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    mContext=context;
    slaveView=null;
    final NumberPicker.Formatter twoDigitFormatter = new NumberPicker.Formatter() {
        final StringBuilder mBuilder = new StringBuilder();
        final java.util.Formatter mFmt = new java.util.Formatter(mBuilder, java.util.Locale.US);
        final Object[] mArgs = new Object[1];
        public String format(int value) {
            mArgs[0] = value;
            mBuilder.delete(0, mBuilder.length());
            mFmt.format("%02d", mArgs);
            return mFmt.toString();
        }
    };

   
    init();
    if (!isEnabled()) {
        setEnabled(false);
    }
}
 
Example 16
Project: Runnest   File: RequestChallengeDialogFragment.java   View source code 6 votes vote down vote up
private void setDividerColor(NumberPicker picker, int color) {

        java.lang.reflect.Field[] pickerFields = NumberPicker.class.getDeclaredFields();
        for (java.lang.reflect.Field pf : pickerFields) {
            if (pf.getName().equals("mSelectionDivider")) {
                pf.setAccessible(true);
                try {
                    ColorDrawable colorDrawable = new ColorDrawable(color);
                    pf.set(picker, colorDrawable);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                break;
            }
        }
    }
 
Example 17
Project: calendarview2   File: CustomTileDimensions.java   View source code 6 votes vote down vote up
@OnClick(R.id.custom_tile_width_size)
public void onWidthClick() {
  final NumberPicker view = new NumberPicker(this);
  view.setMinValue(24);
  view.setMaxValue(64);
  view.setWrapSelectorWheel(false);
  view.setValue(currentTileWidth);
  new AlertDialog.Builder(this)
          .setView(view)
          .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(@NonNull DialogInterface dialog, int which) {
              currentTileWidth = view.getValue();
              widget.setTileWidthDp(currentTileWidth);
            }
          })
          .show();
}
 
Example 18
Project: calendarview2   File: CustomTileDimensions.java   View source code 6 votes vote down vote up
@OnClick(R.id.custom_tile_height_size)
public void onHeightClick() {
  final NumberPicker view = new NumberPicker(this);
  view.setMinValue(24);
  view.setMaxValue(64);
  view.setWrapSelectorWheel(false);
  view.setValue(currentTileHeight);
  new AlertDialog.Builder(this)
          .setView(view)
          .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(@NonNull DialogInterface dialog, int which) {
              currentTileHeight = view.getValue();
              widget.setTileHeightDp(currentTileHeight);
            }
          })
          .show();
}
 
Example 19
Project: calendarview2   File: DynamicSettersActivity.java   View source code 6 votes vote down vote up
@OnClick(R.id.button_set_tile_size)
void onTileSizeClicked() {
    final NumberPicker view = new NumberPicker(this);
    view.setMinValue(24);
    view.setMaxValue(64);
    view.setWrapSelectorWheel(false);
    view.setValue(currentTileSize);
    new AlertDialog.Builder(this)
            .setView(view)
            .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(@NonNull DialogInterface dialog, int which) {
                    currentTileSize = view.getValue();
                    widget.setTileSizeDp(currentTileSize);
                }
            })
            .show();
}
 
Example 20
Project: wallpaperboard   File: RefreshDurationFragment.java   View source code 6 votes vote down vote up
private void setDividerColor (NumberPicker picker) {
    java.lang.reflect.Field[] pickerFields = NumberPicker.class.getDeclaredFields();
    for (java.lang.reflect.Field pf : pickerFields) {
        if (pf.getName().equals("mSelectionDivider")) {
            pf.setAccessible(true);
            try {
                int color = ColorHelper.getAttributeColor(getActivity(), R.attr.colorAccent);
                pf.set(picker, DrawableHelper.getTintedDrawable(
                        getActivity(), R.drawable.numberpicker_divider, color));
            } catch (Exception e) {
                LogUtil.e(Log.getStackTraceString(e));
            }
            break;
        }
    }
}
 
Example 21
Project: iconsole-android   File: BluetoothChatFragment.java   View source code 6 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    //mConversationView = (ListView) view.findViewById(R.id.in);
    mStartButton = (Button) view.findViewById(R.id.button_start);
    mStopButton = (Button) view.findViewById(R.id.button_stop);
    mDisconnectButton = (Button) view.findViewById(R.id.button_disconnect);
    mLevel = (NumberPicker) view.findViewById(R.id.Level);
    mLevel.setMaxValue(32);
    mLevel.setMinValue(1);
    mLevel.setValue(1);
    mLevel.setWrapSelectorWheel(false);
    mLevel.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
    mSpeedText = (TextView) view.findViewById(R.id.Speed);
    mPowerText = (TextView) view.findViewById(R.id.Power);
    mRPMText = (TextView) view.findViewById(R.id.RPM);
    mDistanceText = (TextView) view.findViewById(R.id.Distance);
    mCaloriesText = (TextView) view.findViewById(R.id.Calories);
    mHFText = (TextView) view.findViewById(R.id.Heart);
    mTimeText = (TextView) view.findViewById(R.id.Time);
}
 
Example 22
Project: MobiRNN-EMDL17   File: PhoneActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    controlToggle = (ToggleButton) findViewById(R.id.toggle_control);

    mStatusTextView = (TextView) findViewById(R.id.tv_status);
    mStatusTextView.setMovementMethod(new ScrollingMovementMethod());
    mResultProgress = (ProgressBar) findViewById(R.id.progress);
    mResultProgress.setMax(100);

    NumberPicker picker = (NumberPicker) findViewById(R.id.number_picker);
    picker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
    picker.setOnValueChangedListener(this);
    picker.setDisplayedValues(mSampleSizes);
    picker.setMinValue(0);
    picker.setMaxValue(mSampleSizes.length - 1);
    picker.setWrapSelectorWheel(true);
    picker.setValue(0);
    mSampleSize = 1;
    Logger.i("Sample size initial value: %s", mSampleSize);

    checkPermissions();

}
 
Example 23
Project: android-chessclock   File: TimePickerView.java   View source code 6 votes vote down vote up
/**
 * Set the reference of seconds picker, its digit format and register value change listener.
 *
 * @param pickerVisible if false, removes the spinner widget.
 */
@TargetApi(11)
protected void setupSecondPicker(boolean pickerVisible) {
    mSecondPicker = (NumberPicker) findViewById(R.id.seconds);
    if (pickerVisible) {
        mSecondPicker.setMinValue(0);
        mSecondPicker.setMaxValue(59);
        mSecondPicker.setFormatter(TWO_DIGIT_FORMATTER);
        mSecondPicker.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
            @Override
            public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
                mCurrentSecond = newVal;
            }
        });
    } else {
        mHourPicker.setVisibility(View.GONE);
    }
}
 
Example 24
Project: android-chessclock   File: TimePickerView.java   View source code 6 votes vote down vote up
/**
 * Set the reference of minute picker, its digit format and register value change listener.
 *
 * @param pickerVisible if false, removes the spinner widget.
 */
@TargetApi(11)
protected void setupMinutePicker(boolean pickerVisible) {
    mMinutePicker = (NumberPicker) findViewById(R.id.minute);
    if (pickerVisible) {
        mMinutePicker.setMinValue(0);
        mMinutePicker.setMaxValue(59);
        mMinutePicker.setFormatter(TWO_DIGIT_FORMATTER);
        mMinutePicker.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
            @Override
            public void onValueChange(NumberPicker spinner, int oldVal, int newVal) {
                mCurrentMinute = newVal;
            }
        });
    } else {
        mMinutePicker.setVisibility(View.GONE);
        findViewById(R.id.minute_divider).setVisibility(View.GONE);
    }
}
 
Example 25
Project: android-chessclock   File: TimePickerView.java   View source code 6 votes vote down vote up
/**
 * Set the reference of hour picker, its digit format and register value change listener.
 *
 * @param pickerVisible if false, removes the spinner widget.
 */
@TargetApi(11)
protected void setupHourPicker(boolean pickerVisible) {

    mHourPicker = (NumberPicker) findViewById(R.id.hour);
    if (pickerVisible) {
        mHourPicker.setMinValue(0);
        mHourPicker.setMaxValue(10);
        mHourPicker.setFormatter(TWO_DIGIT_FORMATTER);
        mHourPicker.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
            @Override
            public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
                mCurrentHour = newVal;
            }
        });
    } else {
        mHourPicker.setVisibility(View.GONE);
        findViewById(R.id.hour_divider).setVisibility(View.GONE);
    }
}
 
Example 26
Project: candybar-library   File: CandyBarMuzeiActivity.java   View source code 6 votes vote down vote up
private void setDividerColor (NumberPicker picker) {
    java.lang.reflect.Field[] pickerFields = NumberPicker.class.getDeclaredFields();
    for (java.lang.reflect.Field pf : pickerFields) {
        if (pf.getName().equals("mSelectionDivider")) {
            pf.setAccessible(true);
            try {
                pf.set(picker, ContextCompat.getDrawable(this,
                        Preferences.get(this).isDarkTheme() ?
                                R.drawable.numberpicker_divider_dark :
                                R.drawable.numberpicker_divider));
            } catch (Exception e) {
                LogUtil.e(Log.getStackTraceString(e));
            }
            break;
        }
    }
}
 
Example 27
Project: RPG-Software   File: DiceActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_dice);
    mTextViewResult = (TextView)findViewById(R.id.textView_Result);
    Button buttonThrow = (Button)findViewById(R.id.button_throw);
    final NumberPicker numberPickerMin = (NumberPicker)findViewById(R.id.numberPickerMin);
    final NumberPicker numberPickerMax = (NumberPicker)findViewById(R.id.numberPickerMax);
    numberPickerMin.setMinValue(1);
    numberPickerMin.setMaxValue(100);
    numberPickerMax.setMinValue(1);
    numberPickerMax.setMaxValue(100);
    numberPickerMax.setValue(6);

    buttonThrow.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Dice d = new Dice(numberPickerMin.getValue(),numberPickerMax.getValue());
            int result = d.diceGenerator();
            mTextViewResult.setText("Result : " + result);
        }
    });
}
 
Example 28
Project: MyWorld   File: NewPeriodicCareFragment.java   View source code 6 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_new_periodic_care, container, false);
    goalPicker = (NumberPicker) view.findViewById(R.id.goal_picker);
    punishmentPicker = (NumberPicker) view.findViewById(R.id.punishment_picker);
    lengthPicker = (NumberPicker) view.findViewById(R.id.length_picker);
    unitPicker = (NumberPicker) view.findViewById(R.id.unit_picker);
    goalPicker.setMaxValue(Integer.MAX_VALUE);
    goalPicker.setMinValue(1);
    goalPicker.setWrapSelectorWheel(false);
    punishmentPicker.setMaxValue(Integer.MAX_VALUE);
    punishmentPicker.setMinValue(0);
    punishmentPicker.setValue(1);
    punishmentPicker.setWrapSelectorWheel(false);
    lengthPicker.setMaxValue(Integer.MAX_VALUE);
    lengthPicker.setMinValue(1);
    lengthPicker.setWrapSelectorWheel(false);
    unitPicker.setDisplayedValues(getResources().getStringArray(R.array.period_units));
    unitPicker.setMaxValue(3);
    unitPicker.setMinValue(0);
    unitPicker.setValue(3);
    unitPicker.setWrapSelectorWheel(true);
    return view;
}
 
Example 29
Project: yun2win-sdk-android   File: ChooseDateDialog.java   View source code 6 votes vote down vote up
/**
 * 得到viewGroup里面的numberpicker组件
 * @param viewGroup
 * @return
 */
private List<NumberPicker> findNumberPicker(ViewGroup viewGroup){
    List<NumberPicker> npList = new ArrayList<NumberPicker>();
    View child = null;
    if(null != viewGroup){
        for(int i = 0; i < viewGroup.getChildCount(); i++){
            child = viewGroup.getChildAt(i);
            if(child instanceof NumberPicker){
                npList.add((NumberPicker)child);
            }
            else if(child instanceof LinearLayout){
                List<NumberPicker> result = findNumberPicker((ViewGroup)child);
                if(result.size()>0){
                    return result;
                }
            }
        }
    }
    return npList;
}
 
Example 30
Project: xDrip   File: SnoozeActivity.java   View source code 6 votes vote down vote up
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)));
    }
}
 
Example 31
Project: xDrip   File: SnoozeActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //KS if (Home.get_holo()) { setTheme(R.style.OldAppTheme); }
    setContentView(R.layout.activity_snooze);
    alertStatus = (TextView) findViewById(R.id.alert_status);
    snoozeValue = (NumberPicker) findViewById(R.id.snooze);

    prefs =  PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    doMgdl = (prefs.getString("units", "mgdl").compareTo("mgdl") == 0);

    addListenerOnButton();
    if(BgGraphBuilder.isXLargeTablet(getApplicationContext())) {
        alertStatus.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
        buttonSnooze.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
    }
    displayStatus();
}
 
Example 32
Project: xDrip   File: SnoozeActivity.java   View source code 6 votes vote down vote up
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)));
    }
}
 
Example 33
Project: xDrip   File: SnoozeActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (Home.get_holo()) { setTheme(R.style.OldAppThemeNoTitleBar); }
    JoH.fixActionBar(this);
    setContentView(R.layout.activity_snooze);
    alertStatus = (TextView) findViewById(R.id.alert_status);
    snoozeValue = (NumberPicker) findViewById(R.id.snooze);

    prefs =  PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    doMgdl = (prefs.getString("units", "mgdl").compareTo("mgdl") == 0);

    addListenerOnButton();
    if(BgGraphBuilder.isXLargeTablet(getApplicationContext())) {
        alertStatus.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
        buttonSnooze.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
    }
    displayStatus();
}
 
Example 34
Project: xDrip-plus   File: SnoozeActivity.java   View source code 6 votes vote down vote up
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)));
    }
}
 
Example 35
Project: xDrip-plus   File: SnoozeActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //KS if (Home.get_holo()) { setTheme(R.style.OldAppTheme); }
    setContentView(R.layout.activity_snooze);
    alertStatus = (TextView) findViewById(R.id.alert_status);
    snoozeValue = (NumberPicker) findViewById(R.id.snooze);

    prefs =  PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    doMgdl = (prefs.getString("units", "mgdl").compareTo("mgdl") == 0);

    addListenerOnButton();
    if(BgGraphBuilder.isXLargeTablet(getApplicationContext())) {
        alertStatus.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
        buttonSnooze.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
    }
    displayStatus();
}
 
Example 36
Project: xDrip-plus   File: SnoozeActivity.java   View source code 6 votes vote down vote up
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)));
    }
}
 
Example 37
Project: xDrip-plus   File: SnoozeActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (Home.get_holo()) { setTheme(R.style.OldAppThemeNoTitleBar); }
    JoH.fixActionBar(this);
    setContentView(R.layout.activity_snooze);
    alertStatus = (TextView) findViewById(R.id.alert_status);
    snoozeValue = (NumberPicker) findViewById(R.id.snooze);

    prefs =  PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    doMgdl = (prefs.getString("units", "mgdl").compareTo("mgdl") == 0);

    addListenerOnButton();
    if(BgGraphBuilder.isXLargeTablet(getApplicationContext())) {
        alertStatus.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
        buttonSnooze.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
    }
    displayStatus();
}
 
Example 38
Project: DialogAlchemy   File: NumberPickerStone.java   View source code 6 votes vote down vote up
@Override
public void bindView(Dialog dialog) {
    textView = (TextView) dialog.findViewById(R.id.description);
    numberPicker = (NumberPicker) dialog.findViewById(R.id.number_picker);

    textView.setText(description);

    numberPicker.setMaxValue(maxValue != null ? maxValue : 24);
    numberPicker.setMinValue(minValue != null ? minValue : 1);
    numberPicker.setOnLongPressUpdateInterval(100);
    numberPicker.setWrapSelectorWheel(false);
    if (currentValue != null) {
        numberPicker.setValue(currentValue);
    }
    if (!canUseKeyBoard) {
        numberPicker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
    }
}
 
Example 39
Project: YingBeautyNote   File: DateTimePicker.java   View source code 6 votes vote down vote up
@Override
public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
    int minValue = mMinuteSpinner.getMinValue();
    int maxValue = mMinuteSpinner.getMaxValue();
    int offset = 0;
    if (oldVal == maxValue && newVal == minValue) {
        offset += 1;
    } else if (oldVal == minValue && newVal == maxValue) {
        offset -= 1;
    }
    if (offset != 0) {
        mDate.add(Calendar.HOUR_OF_DAY, offset);
        mHourSpinner.setValue(getCurrentHour());
        updateDateControl();
        int newHour = getCurrentHourOfDay();
        if (newHour >= HOURS_IN_HALF_DAY) {
            mIsAm = false;
            updateAmPmControl();
        } else {
            mIsAm = true;
            updateAmPmControl();
        }
    }
    mDate.set(Calendar.MINUTE, newVal);
    onDateTimeChanged();
}
 
Example 40
Project: medical-data-android   File: TestActivity.java   View source code 6 votes vote down vote up
/**
 * Auxiliar function to get questions 8 to 10 value and set an error if they have not been
 * answered.
 *
 * @param i     Number of question
 * @param id    {@link RatingStars} id
 * @param text  {@link TextView} id of the question title
 * @param error {@link TextView} title of the first question title whose question has an error
 * @return <code>true</code> if an error was set; <code>false</code> otherwise.
 */
private TextView NumberPickerAnswered(int i, int id, int text, TextView error) {
    NumberPicker np = (NumberPicker) findViewById(id);
    int value = np.getValue();
    TextView tv = (TextView) findViewById(text);
    if (value == 0) {
        tv.setError("");
        if (error == null) {
            return tv;
        }
    } else {
        questions[i] = ((i == 7) ? (value - 1) * 10 : (value - 1));
        tv.setError(null);
    }
    return error;
}