本文整理汇总了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);
}
}
示例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);
}
示例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;
}