title: While loop causes UI to go blank
body: <p>I'm writing a simple Whack a Mole clone, and I've got my UI elements declared in a GridLayout in a layout.xml, then assigned to ImageView variables in an array programmatically.  I've got a startGame() method that simply takes a random int, pulls it from the array and causes it to go visible for a second, then repeats.  For some reason, when I put this code in a while() loop, it causes my UI to go blank as soon as it's launched.  </p>
  
  <p>I know it's the while() loop because I tried taking the code out of the while() loop, and it ran correctly (once), but turns everything white when placed in a while loop.</p>
  
  <p>Here's the method causing the problem:</p>
  
  <pre><code>public void startGame() {
      gameStarted = true;
      while(gameStarted) {
          randomInt = rand.nextInt(11);
          mole[randomInt].setVisibility(View.VISIBLE);
  
          handler.postDelayed(new Runnable() {
              @Override
              public void run() {
                  mole[randomInt].setVisibility(View.INVISIBLE);
              }
          }, 5000);
      }
  }
  </code></pre>
  
  <p>All the other relevant code is in onCreate, it's otherwise just a skeleton Activity subclass.</p>
  
  <pre><code>public class WAM_Activity extends Activity {
  
      private ImageView[] mole = new ImageView[11];
      private int[] moleId = {R.id.mole1, R.id.mole3, R.id.mole4, R.id.mole5, R.id.mole6, R.id.mole7, R.id.mole8, R.id.mole9, R.id.mole10, R.id.mole11, R.id.mole12};
      private boolean gameStarted;
      private int randomInt = 0;
      private Random rand = new Random();
      Handler handler = new Handler();
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.wam_view_layout);
  
          for (int i = 0; i &lt; 11; i++) {
              mole[i] = (ImageView) findViewById(moleId[i]);
              mole[i].setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View view) {
                      //do stuff eventually
                  }
              });
          }
          gameStarted = true;
          startGame();
  
      }
  </code></pre>
  
  <p>Any idea why this isn't working?  I've been staring at it for hours and I'm quite stumped.</p>