title: How to wait for code executing in Android? Runnable failed for me
body: <p>I want to wait inside my while loop for like 1 second <strong>each time it is inside the loop.</strong></p>
  
  <p>I tryed with Runnable:</p>
  
  <pre><code>new Handler().postDelayed(new Runnable() 
  {
      @Override
      public void run() 
      {
          int i=0;
  
          while(i&lt;10){
              if(i%2 ==0){
  
                  myTextView.setText("true");
              }
              else{
  
                  myTextView.setText("false");
              }
  
              i++;
          }
      }
  }, 1000);
  </code></pre>
  
  <p>If i ran this code i got a blank display for minutes and then a crash.</p>
  
  <p>Logcat:</p>
  
  <pre><code> ActivityManager      Reason: keyDispacthingTimeot
  </code></pre>
  
  <p>What is the problem?
  I would like to make this as simple as it can be...</p>
  
  <p>Please help!</p>