Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

152
Visualizações
Reset counts after disabled button is enabled in android studio

So i have a count button which disabled for two hours lets say 1am to 3am. I want to reset counter when the button is enabled again.

For example.

I have a counter which has 40 counts right now .the time is 1am and counter button is disabled for two hours it will enable on 3am. So i want when counter button is enabled on 3am counts should be zero after 3 am.

I hope you get what i am trying to say. I will try to explain once more. Right now time is 12am and the counts are 40. Now time is 1am and now count button is disabled for two hours .at 3am count button is enabled so at this point of time i want my counts to be zero.

Here is my java code for counter.

            @Override
            public void onClick(View v) {
                int hours = new Time(System.currentTimeMillis ()).getHours();
                if(hours == 23 || hours == 24||hours == 01){
                    //Disable
                }else{
                    //Enable
                    count10counter++;
                }
                count10.saveTotalInPrefcount10 ( getApplicationContext (),count10counter );
                tvcount10.setText ( Integer.toString ( count10counter ) );
                Toast.makeText ( getApplicationContext (),"you clicked 10",Toast.LENGTH_SHORT ).show ();
            }
        } );  ```






I also have reset button but that reset button can be clicked by every user and i dont want.only i or admin should be able to click reset button.if someone has any suggestions on this please suggest me.

``` RESET.setOnClickListener ( new View.OnClickListener ( ) {
           @Override
           public void onClick(View arg0) {

               count10counter=0;
               tvcount10.setText ( String.valueOf ( count10counter ) );

           }
       } );```
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda