How to put Double zero (00) to a NumberPicker

0

I have this code and I could not make the NumberPicker in the 00 as I have it there, only the 0 is seen alone.

numberPicker.setMaxValue(59);
numberPicker.setMinValue(00);
numberPicker.setValue(3);

btnCalcular.setOnClickListener(new OnClickListener(){
  @Override
  public void onClick(View v){
    if(numberPicker.getValue()<10){
      txtDato.setText("Valor de number "+0+numberPicker.getValue());
    }else{
      txtDato.setText("Valor de number "+numberPicker.getValue());
    }
  }
});
    
asked by Herson Viveros 30.08.2018 в 01:06
source

1 answer

0

You can use setFormatter to apply a format to the number picker.

numberPicker.setMaxValue(59);
numberPicker.setMinValue(0);
numberPicker.setValue(3);
numberPicker.setFormatter(new NumberPicker.Formatter() {
        @Override
        public String format(int i) {
            return String.format("%02d", i);
        }
    });
    
answered by 30.08.2018 / 04:55
source