NumberPicker setValue - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for NumberPicker setValue method.

This code example shows how to use the following methods:setDisplayedValues, setMaxValue, setMinValue, setValue, setWrapSelectorWheel
 
    /** 
     * This method should be subclassed to update the spinners based on mCurrentDate. 
     */ 
    protected void updateSpinners() { 
        mPositionInYearSpinner.setDisplayedValues(null);
 
        // set the spinner ranges respecting the min and max dates 
        mPositionInYearSpinner.setMinValue(getMinPositionInYear());
        mPositionInYearSpinner.setMaxValue(getMaxPositionInYear());
        mPositionInYearSpinner.setWrapSelectorWheel(
                !mCurrentDate.equals(mMinDate) && !mCurrentDate.equals(mMaxDate));
 
        // year spinner range does not change based on the current date 
        mYearSpinner.setMinValue(getMinYear());
        mYearSpinner.setMaxValue(getMaxYear());
        mYearSpinner.setWrapSelectorWheel(false);
 
        // set the spinner values 
        mYearSpinner.setValue(getYear());

7
CodeRank
This code example shows how to use the following methods:setValue
 
    @Override 
    public void onRestoreInstanceState(Bundle savedInstanceState) {
        super.onRestoreInstanceState(savedInstanceState);
        int number = savedInstanceState.getInt(NUMBER);
        mNumberPicker.setValue(number);
    } 
} 
6
CodeRank
This code example shows how to use the following methods:getMaxValue, setValue
            mTimeLapseSwitch.setChecked(false);
            setTimeSelectionEnabled(false); 
        } else { 
            mTimeLapseSwitch.setChecked(true);
            setTimeSelectionEnabled(true); 
            int durationCount = mNumberSpinner.getMaxValue() + 1;
            int unit = (index - 1) / durationCount;
            int number = (index - 1) % durationCount;
            mUnitSpinner.setValue(unit);
            mNumberSpinner.setValue(number);
        } 
    } 
 
    @Override 
    public void setVisibility(int visibility) {
        if (visibility == View.VISIBLE) {
            if (getVisibility() != View.VISIBLE) {
                // Set the number pickers and on/off switch to be consistent 
                // with the preference 
                restoreSetting(); 
6
CodeRank
This code example shows how to use the following methods:setDisplayedValues, setMaxValue, setMinValue, setValue, setWrapSelectorWheel
 
    /** 
     * This method should be subclassed to update the spinners based on mCurrentDate. 
     */ 
    protected void updateSpinners() { 
        mPositionInYearSpinner.setDisplayedValues(null);
 
        // set the spinner ranges respecting the min and max dates 
        mPositionInYearSpinner.setMinValue(getMinPositionInYear());
        mPositionInYearSpinner.setMaxValue(getMaxPositionInYear());
        mPositionInYearSpinner.setWrapSelectorWheel(
                !mCurrentDate.equals(mMinDate) && !mCurrentDate.equals(mMaxDate));
 
        // year spinner range does not change based on the current date 
        mYearSpinner.setMinValue(getMinYear());
        mYearSpinner.setMaxValue(getMaxYear());
        mYearSpinner.setWrapSelectorWheel(false);
 
        // set the spinner values 
        mYearSpinner.setValue(getYear());

6
CodeRank
This code example shows how to use the following methods:setMaxValue, setMinValue, setOnValueChangedListener, setValue
    setButton(-1, localContext.getText(2131493337), this);
    setIcon(0);
    View localView = ((LayoutInflater)localContext.getSystemService("layout_inflater")).inflate(2130903181, null);
    setView(localView);
    this.a = ((NumberPicker)localView.findViewById(2131165624));
    this.a.setMinValue(paramInt3);
    this.a.setMaxValue(paramInt4);
    this.a.setValue(paramInt2);
    this.a.setOnValueChangedListener(this);
    setTitle(paramString);
  } 
 
  public m(Context paramContext, n paramn, int paramInt1, int paramInt2, int paramInt3, String paramString)
  { 
    this(paramContext, 0, paramn, paramInt1, paramInt2, paramInt3, paramString);
  } 
 
  private void a() 
  { 
    if (this.b != null)
6
CodeRank
This code example shows how to use the following methods:setMaxValue, setMinValue, setOnValueChangedListener, setValue
        @Override  
        protected View onCreateDialogView() {
            //Create Views 
            LinearLayout dialogLayout = new LinearLayout(mCtx);
            mTvDialogMessage = new TextView(mCtx);
            mNumberPicker = new NumberPicker(mCtx);
 
            //Set View attributes 
            dialogLayout.setOrientation(LinearLayout.VERTICAL);
            if (mDialogMessage!=null)
                mTvDialogMessage.setText(mDialogMessage);
            dialogLayout.addView(mTvDialogMessage);
            mNumberPicker.setOnValueChangedListener(this);
            dialogLayout.addView(mNumberPicker, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
            if (shouldPersist()) 
                mValue = getPersistedInt(mDefault);
            mNumberPicker.setMaxValue(mMax);
            mNumberPicker.setMinValue(1);
            mNumberPicker.setValue(mValue);
             

6
CodeRank
This code example shows how to use the following methods:setEnabled, setMaxValue, setMinValue, setValue, setWrapSelectorWheel
	public int initializeStuff() { 
		int maxVolume = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
		 
		npHeadphone.setMaxValue(maxVolume);
		npHeadphone.setMinValue(1);
		npSpeaker.setMaxValue(maxVolume);
		npSpeaker.setMinValue(1);
		npHeadphone.setWrapSelectorWheel(false);
		npSpeaker.setWrapSelectorWheel(false);
		 
		npHeadphone.setValue(maxVolume/2); //initalize value in the picker
		npSpeaker.setValue(maxVolume/2);
		 
		//npHeadphone.setEnabled(false); //disable changes for headphone on initialization 
		npSpeaker.setEnabled(false);
		 
		return maxVolume;
		 
	} 
	 
6
CodeRank
This code example shows how to use the following methods:setFocusable, setFocusableInTouchMode, clearFocus, hasFocus, setEnabled
6
CodeRank
This code example shows how to use the following methods:setMaxValue, setMinValue, setValue
    private void updateDaySpinner() { 
        Calendar cal = Calendar.getInstance();
        // if year was not set, use 2000 as it was a leap year 
        cal.set(mHasYear ? mYear : 2000, mMonth, 1);
        int max = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
        mDayPicker.setMinValue(1);
        mDayPicker.setMaxValue(max);
        mDayPicker.setValue(mDay);
    } 
 
    public int getYear() { 
        return (mYearOptional && !mHasYear) ? 0 : mYear;
    } 
 
    public int getMonth() { 
        return mMonth;
    } 
 
    public int getDayOfMonth() { 
        return mDay;
5
CodeRank
This code example shows how to use the following methods:setValue
		// Cast state to custom BaseSavedState and pass to superclass 
		SavedState myState = (SavedState) state;
		super.onRestoreInstanceState(myState.getSuperState());
 
		// Set this Preference's widget to reflect the restored state 
		mNumberPicker.setValue(myState.value);
	} 
 
	private static class SavedState extends BaseSavedState {
		// Member that holds the setting's value 
		// Change this data type to match the type saved by your Preference 
		int value;
 
		public SavedState(Parcelable superState) {
			super(superState);
		} 
 
		public SavedState(Parcel source) {
			super(source);
			// Get the current preference's value 
6
CodeRank

Related NumberPicker setValue Questions & Answers:

setValue Method Overview
Set the current value for the number picker.
See Code Examples for other Android NumberPicker Methods: