title: Why Postdelayed is not working in the if statement
body: <p>Why does the timer stop working when i put the <code>postDelayed(this,1000);</code>  inside the if statement, just under <code>seconds++;</code>?
  There are 3 buttons (start,stop,reset) in the layout. Press Start->running=true,press stop->running=stop,press reset->running=false seconds=0</p>
  
  <pre><code>private void runTimer() {
  
      final TextView timeView = (TextView) findViewById(R.id.time_view);
      final Handler handler = new Handler();
  
      handler.post(new Runnable() {
  
          @Override
          public void run() {
              int hours = seconds / 3600;
              int minutes = (seconds % 3600) / 60;
              int secs = seconds % 60;
  
              String time = String.format("%d:%2d:%02d", hours, minutes, secs);
              timeView.setText(time);
              if (running) {
                  seconds++;
              //handler.postDelayed(this, 1000);
              //doesnt work if i put it here
              }
              handler.postDelayed(this, 1000);
          }
      });
  
  }
  </code></pre>