Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

153
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda