當前位置: 首頁>>代碼示例>>Java>>正文


Java NumberPicker.setFormatter方法代碼示例

本文整理匯總了Java中android.widget.NumberPicker.setFormatter方法的典型用法代碼示例。如果您正苦於以下問題:Java NumberPicker.setFormatter方法的具體用法?Java NumberPicker.setFormatter怎麽用?Java NumberPicker.setFormatter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.NumberPicker的用法示例。


在下文中一共展示了NumberPicker.setFormatter方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initNumPicker

import android.widget.NumberPicker; //導入方法依賴的package包/類
/**
 * 初始化傳入的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

}
 
開發者ID:GrayXu,項目名稱:HustEating,代碼行數:26,代碼來源:SettingFragment.java

示例2: setupSecondPicker

import android.widget.NumberPicker; //導入方法依賴的package包/類
/**
 * 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);
    }
}
 
開發者ID:ChessCom,項目名稱:android-chessclock,代碼行數:23,代碼來源:TimePickerView.java

示例3: setupMinutePicker

import android.widget.NumberPicker; //導入方法依賴的package包/類
/**
 * 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);
    }
}
 
開發者ID:ChessCom,項目名稱:android-chessclock,代碼行數:24,代碼來源:TimePickerView.java

示例4: setupHourPicker

import android.widget.NumberPicker; //導入方法依賴的package包/類
/**
 * 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);
    }
}
 
開發者ID:ChessCom,項目名稱:android-chessclock,代碼行數:25,代碼來源:TimePickerView.java

示例5: TimeLimitationPicker

import android.widget.NumberPicker; //導入方法依賴的package包/類
public TimeLimitationPicker(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    LayoutInflater.from(context).inflate(R.layout.item_time_limitation_picker, this);
    title = (TextView) findViewById(R.id.title);
    startHourPicker = (NumberPicker) findViewById(R.id.start_hour_picker);
    startMinutePicker = (NumberPicker) findViewById(R.id.start_minute_picker);
    endHourPicker = (NumberPicker) findViewById(R.id.end_hour_picker);
    endMinutePicker = (NumberPicker) findViewById(R.id.end_minute_picker);
    NumberPicker.Formatter formatter = new NumberPicker.Formatter() {
        @Override
        public String format(int value) {
            return String.format("%02d", value);
        }
    };
    startHourPicker.setMaxValue(23);
    startHourPicker.setMinValue(0);
    startHourPicker.setValue(7);
    startHourPicker.setFormatter(formatter);
    startHourPicker.setWrapSelectorWheel(true);
    startMinutePicker.setMaxValue(59);
    startMinutePicker.setMinValue(0);
    startMinutePicker.setValue(0);
    startMinutePicker.setFormatter(formatter);
    startMinutePicker.setWrapSelectorWheel(true);
    endHourPicker.setMaxValue(23);
    endHourPicker.setMinValue(0);
    endHourPicker.setValue(7);
    endHourPicker.setFormatter(formatter);
    endHourPicker.setWrapSelectorWheel(true);
    endMinutePicker.setMaxValue(59);
    endMinutePicker.setMinValue(0);
    endMinutePicker.setValue(0);
    endMinutePicker.setFormatter(formatter);
    endMinutePicker.setWrapSelectorWheel(true);
}
 
開發者ID:OneCivilization,項目名稱:MyWorld,代碼行數:36,代碼來源:TimeLimitationPicker.java

示例6: prepareNumberPicker

import android.widget.NumberPicker; //導入方法依賴的package包/類
/**
 * Customizes the options shown in the {@link NumberPicker}s to represent i with the string
 * i - 1 and 0 with a blank option
 *
 * @param id
 */
private void prepareNumberPicker(int id) {
    NumberPicker np = (NumberPicker) findViewById(id);
    np.setMinValue(0);
    np.setMaxValue(1001);
    np.setWrapSelectorWheel(false);
    np.setFormatter(new NumberPicker.Formatter() {
        @Override
        public String format(int i) {
            if (i == 0) return " ";
            return String.valueOf(i - 1);
        }
    });
}
 
開發者ID:Ana06,項目名稱:medical-data-android,代碼行數:20,代碼來源:TestActivity.java

示例7: prepareCaffeineNumberPicker

import android.widget.NumberPicker; //導入方法依賴的package包/類
/**
 * Customizes the options shown in the {@link NumberPicker}s to represent i with the string
 * (i - 1) * 10 and 0 with a blank option. That means that the step for the caffeine is 10
 * instead of 1
 *
 * @param id
 */
private void prepareCaffeineNumberPicker(int id) {
    NumberPicker np = (NumberPicker) findViewById(id);
    np.setMinValue(0);
    np.setMaxValue(10010);
    np.setWrapSelectorWheel(false);
    np.setFormatter(new NumberPicker.Formatter() {
        @Override
        public String format(int i) {
            if (i == 0) return " ";
            return String.valueOf((i - 1) * 10);
        }
    });
}
 
開發者ID:Ana06,項目名稱:medical-data-android,代碼行數:21,代碼來源:TestActivity.java

示例8: onBindDialogView

import android.widget.NumberPicker; //導入方法依賴的package包/類
@Override
protected void onBindDialogView(View view) {
    String[] values = mCurrentTime.split(":");
    int hours = Integer.valueOf(values[0]);
    int minutes = Integer.valueOf(values[1]);
    int seconds = Integer.valueOf(values[2]);

    mHourPicker = (NumberPicker) view.findViewById(R.id.hour);
    mHourPicker.setMinValue(0);
    mHourPicker.setMaxValue(10);
    mHourPicker.setFormatter(TWO_DIGITS_FORMATTER);
    mHourPicker.setValue(hours);
    mHourPicker.setOnValueChangedListener(this); // min time is 5s

    mMinutePicker = (NumberPicker) view.findViewById(R.id.minute);
    mMinutePicker.setMinValue(0);
    mMinutePicker.setMaxValue(59);
    mMinutePicker.setFormatter(TWO_DIGITS_FORMATTER);
    mMinutePicker.setValue(minutes);
    mMinutePicker.setOnValueChangedListener(this); // min time is 5s

    mSecondPicker = (NumberPicker) view.findViewById(R.id.seconds);
    mSecondPicker.setMinValue(0); // see onValueChange method
    mSecondPicker.setMaxValue(59);
    mSecondPicker.setFormatter(TWO_DIGITS_FORMATTER);
    mSecondPicker.setValue(seconds);
    mSecondPicker.setOnValueChangedListener(this); // min time is 5s

    super.onBindDialogView(view);
}
 
開發者ID:dielsonsales,項目名稱:OpenPomodoro,代碼行數:31,代碼來源:TimePreference.java

示例9: onCreateView

import android.widget.NumberPicker; //導入方法依賴的package包/類
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_new_time_limited_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);
    startHourPicker = (NumberPicker) view.findViewById(R.id.start_hour_picker);
    startMinutePicker = (NumberPicker) view.findViewById(R.id.start_minute_picker);
    endHourPicker = (NumberPicker) view.findViewById(R.id.end_hour_picker);
    endMinutePicker = (NumberPicker) view.findViewById(R.id.end_minute_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);
    NumberPicker.Formatter formatter = new NumberPicker.Formatter() {
        @Override
        public String format(int value) {
            return String.format("%02d", value);
        }
    };
    startHourPicker.setMaxValue(23);
    startHourPicker.setMinValue(0);
    startHourPicker.setValue(7);
    startHourPicker.setFormatter(formatter);
    startHourPicker.setWrapSelectorWheel(true);
    startMinutePicker.setMaxValue(59);
    startMinutePicker.setMinValue(0);
    startMinutePicker.setValue(0);
    startMinutePicker.setFormatter(formatter);
    startMinutePicker.setWrapSelectorWheel(true);
    endHourPicker.setMaxValue(23);
    endHourPicker.setMinValue(0);
    endHourPicker.setValue(7);
    endHourPicker.setFormatter(formatter);
    endHourPicker.setWrapSelectorWheel(true);
    endMinutePicker.setMaxValue(59);
    endMinutePicker.setMinValue(0);
    endMinutePicker.setValue(0);
    endMinutePicker.setFormatter(formatter);
    endMinutePicker.setWrapSelectorWheel(true);
    return view;
}
 
開發者ID:OneCivilization,項目名稱:MyWorld,代碼行數:56,代碼來源:NewTimeLimitedPeriodicCareFragment.java


注:本文中的android.widget.NumberPicker.setFormatter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。