title: Implementing traffic signal in Android
body: <p>I'm trying to implement a traffic signal which will change color form red to green then to yellow. For this I used a button and I'm changing the background of the button to respected color. I'm using <code>CountDownTimer</code> for this purpose. Here is my code:    </p>
  
  <pre><code>public class MainActivity extends Activity {
  
      Button button1 = null;
      @Override
      protected void onCreate(Bundle savedInstanceState) 
      {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          button1 = (Button) findViewById(R.id.button1);
          button1.setBackgroundColor(Color.RED);
          while(true){
              change(Color.GREEN);
              change(Color.BLUE);
              change(Color.RED);
          }
      }
  
      void change(final int color) 
      {
          CountDownTimer ctd = new CountDownTimer(3000, 3000) 
          {
  
              @Override
              public void onTick(long arg0) {}
  
              @Override
              public void onFinish() {
                  button1.setBackgroundColor(color);
              }
          };
          ctd.start();
      }
  }
  </code></pre>
  
  <p>But the above code doesn't seems to work, the color of the button is not at all changing. What's the problem in this code?</p>