title: How to refresh a TextView while looping in Android?
body: <p>I have this:</p>
  
  <pre><code>public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
  
  
      TextView debugView = (TextView)findViewById(R.id.debugView);
  
      for(int i=0;i&lt;100;i++) {
          try {
              Thread.sleep(100);
          } catch (InterruptedException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
          debugView.setText(Integer.toString(i));
      }
  
  }
  </code></pre>
  
  <p>I would expect it to update the text view each time through the loop so I would get:
  1, 2, 3, ... 99</p>
  
  <p>Instead the app does nothing for 10 seconds and then outputs: 99</p>
  
  <p>I am guessing that I need the TextView to refresh during the loop.  I am new to Android development.  Can somebody please tell me if this is the best way to accomplish this?</p>
  
  <p>My eventually goal is to be able to process audio samples to build a guitar tuner.  I am trying to simply verify visually that the app is responding to external audio and I want to update a TextView to demonstrate that.  Please advise if there is a better way to do this.</p>