How do you display a 2 digit NumberPicker in android?

前端 未结 3 734
渐次进展
渐次进展 2021-02-19 05:22

I want to create a timer and since I couldn\'t create a digital interface that is editable for the user to set the time I want to use the NumberPicker. However the NumberPicker

相关标签:
3条回答
  • 2021-02-19 05:54
     NumberPicker monthPicker = (NumberPicker) view.findViewById(R.id.np_month);
            monthPicker.setMinValue(1);
            monthPicker.setMaxValue(12);
            monthPicker.setFormatter(new NumberPicker.Formatter() {
                @Override
                public String format(int i) {
                    return String.format("%02d", i);
                }
            });
    
    0 讨论(0)
  • 2021-02-19 05:56
        numberPicker.setMaxValue(10);
        numberPicker.setMinValue(0);
        numberPicker.setFormatter(new NumberPicker.Formatter() {
            @Override
            public String format(int i) {
                return String.format("%02d", i);
            }
        });
    

    This will do the trick!

    enter image description here

    0 讨论(0)
  • 2021-02-19 06:00

    Implement a custom NumberPicker.Formatter that implements your value display padding and call setFormatter.

    0 讨论(0)
提交回复
热议问题