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


Java NumberPicker.Formatter方法代碼示例

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


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

示例1: SubtitleDelayTVPicker

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

示例2: 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

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