mercredi 9 août 2017

How to make a method similar to on / off button using if-else

I try to put the control of the chronometer on the button, for start and stop. Tried to implement it, but the result is not the same, help with the advice?

 public void onStartClick(View view){
    mChronometer.setBase(SystemClock.elapsedRealtime());
    if(mButton.isPressed()==false){
        mChronometer.start();}else{
        mChronometer.stop();
    }
}

Aucun commentaire:

Enregistrer un commentaire