title: Toggle button visibility in for-loop
body: <p>It must work, but is not working. When i start the app i see a button. Now i want that the button is visible and invisible.</p>
  
  <pre><code>for (k = 0; k &lt; abc.length; ++k) {
  try {
  
      if (k%2 != 0) {
          button.setVisibility(View.VISIBLE);
      } else {
          button.setVisibility(View.GONE);
      }
  
      Thread.sleep(sleepMilliseconds);
  
  } catch (InterruptedException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
  }
  }
  </code></pre>
  
  <p>Or is the for loop so fast, that the android can't show it?
  Nothing happens. I see the button. </p>
  
  <p>I have a Thread.sleep(). Sleep Milliseconds is e.g. 100, 300 -> random. Also it can't be so fast.</p>