Code example for NumberPicker

Methods: setValue, setVisibility

0
    public void set24HourView(boolean is24HourView) {
        if (mIs24HourView == is24HourView) {
            return; 
        } 
        mIs24HourView = is24HourView;
        mAmPmSpinner.setVisibility(is24HourView ? View.GONE : View.VISIBLE);
        int hour = getCurrentHourOfDay();
        updateHourControl(); 
        setCurrentHour(hour);
        updateAmPmControl(); 
    } 
 
    private void updateDateControl() { 
        Calendar cal = Calendar.getInstance();
        cal.setTimeInMillis(mDate.getTimeInMillis());
        cal.add(Calendar.DAY_OF_YEAR, -DAYS_IN_ALL_WEEK / 2 - 1);
        mDateSpinner.setDisplayedValues(null);
        for (int i = 0; i < DAYS_IN_ALL_WEEK; ++i) {
            cal.add(Calendar.DAY_OF_YEAR, 1);
            mDateDisplayValues[i] = (String) DateFormat.format("MM.dd EEEE", cal);
        } 
        mDateSpinner.setDisplayedValues(mDateDisplayValues);
        mDateSpinner.setValue(DAYS_IN_ALL_WEEK / 2);
        mDateSpinner.invalidate();
    } 
 
    private void updateAmPmControl() { 
        if (mIs24HourView) {
            mAmPmSpinner.setVisibility(View.GONE);
        } else { 
            int index = mIsAm ? Calendar.AM : Calendar.PM;
            mAmPmSpinner.setValue(index);
            mAmPmSpinner.setVisibility(View.VISIBLE);
        } 
    } 
 
    private void updateHourControl() { 
        if (mIs24HourView) {