ill*_*s69 14 java xml android numberpicker
我想创建一个计时器,因为我无法创建一个可编辑的数字界面,用户可以设置我想要使用NumberPicker的时间.但是,NumberPicker仅显示0-9之间的数字的1位数.如何格式化选择器,使其显示两个数字,如01 02 03等.
Nav*_*wal 37
numberPicker.setMaxValue(10);
numberPicker.setMinValue(0);
numberPicker.setFormatter(new NumberPicker.Formatter() {
@Override
public String format(int i) {
return String.format("%02d", i);
}
});
Run Code Online (Sandbox Code Playgroud)
这样就可以了!

小智 5
实现一个自定义NumberPicker.Formatter来实现您的值显示填充并调用setFormatter。
| 归档时间: |
|
| 查看次数: |
8374 次 |
| 最近记录: |