title: Nested onClick Listener
body: <p>I have some codes that I need help with. My plan for this code is simple. I have 3 <code>buttons</code> which are the <code>yellowBar</code>, <code>greenBar</code> and <code>redBar</code>. I also have 3 images that is colored yellow, green and red. What I wanted to do is when I start my app, the images I have will randomly pop out and whichever color comes out, I should be able to click the button with the corresponding color. I also have a time, so basically I want to click correctly as much as possible, but my code only runs it one time. my time continues to go down but this code only runs one time. How can I fix this so that it will continue to pop random color images until the time runs out?</p>
  
  <pre><code>while(gameTime &gt; 0){
                  colorNum = new Random();
                  colorNumber = colorNum.nextInt(2);
  
                  switch (colorNumber){
                      case 0: colors.setDisplayedChild(0);
                              break;
  
                      case 1: colors.setDisplayedChild(1);
                              break;
  
                      case 2: colors.setDisplayedChild(2);
                              break;
                  }
                  colors.setVisibility(View.VISIBLE);
                  yellowBar.setOnClickListener(new View.OnClickListener(){
  
                      @Override
                      public void onClick(View v){
                          if(colorNumber == 0){
                              points ++;
                              score.setText(String.valueOf(points));
                          }
                      }
                  });
                  greenBar.setOnClickListener(new View.OnClickListener(){
  
                      @Override
                      public void onClick(View v){
                          if(colorNumber == 1){
                              points ++;
                              score.setText(String.valueOf(points));
                          }
                      }
                  });
                  redBar.setOnClickListener(new View.OnClickListener(){
  
                      @Override
                      public void onClick(View v){
                          if(colorNumber == 2){
                              points++;
                              score.setText(String.valueOf(points));
                          }
                      }
                  });
  
              }
  </code></pre>