Format the Chronometer

0

In my application I inserted a chronometer that simulates a game time ... but when I click on stop and then continue it shows me in format (00: 00: 00: 00) and wanted to show me again in ( 00:00)

NOTE: show me in milliseconds

code:

private Chronometer reloginho;
long tempoPausado = 0;

     imgButton_play.setEnabled(true);
            imgButton_pause.setEnabled(false);
            imgButton_1.setEnabled(false);
            imgButton_2.setEnabled(false);


            imgButton_play.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    imgButton_play.setEnabled(false);
                    imgButton_pause.setEnabled(true);
                    imgButton_1.setEnabled(true);
                    imgButton_2.setEnabled(true);

                    reloginho.setBase(SystemClock.elapsedRealtime());
                    reloginho.start();
                    reloginho.setBase(SystemClock.elapsedRealtime() + tempoPausado);
                }
            });

            imgButton_pause.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    imgButton_play.setEnabled(true);
                    imgButton_pause.setEnabled(false);
                    imgButton_1.setEnabled(false);
                    imgButton_2.setEnabled(false);

                    tempoPausado = reloginho.getBase();
                    SystemClock.elapsedRealtime();
                    reloginho.stop();
                }
            });

Thank you ...

    
asked by anonymous 23.10.2016 / 04:39

1 answer

0

As you said already have formatted text being displayed, it should be in some textview or something, am I right? so, you just convert this time into a string, try something like this:

    //...
    SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
    Date hora = reloginho.getInstance().getTime(); // Ou qualquer outra forma que tem
    String horaFormatada = sdf.format(hora);
    //...
    relogioTextView.setText(horaFormatada);
    //...

Hope this is it !!

Health and Peace!

    
23.10.2016 / 17:48