title: Update Textview from function Android
body: <p>someone can tell me how to update a control Textview Android from a function? I have searched deep into the internet and see many people who ask the same question, I tested threads but could not work, someone has a simple working example of doing this? for example to call a function (which runs several times in a loop) and the function writes in the TextView, but the problem is that until the function is not finished running, it shows me the text.</p>
  
  <pre><code>@Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
  
      while(condition) //here freezes the UI and the text in textview only shows when the loop ends
      {
          HardWork();  
      }
  
  }
  
  public void HardWork() {  
  
      txtProgreso.append("Test Line" + "\n\n");
  
  };
  </code></pre>
  
  <p>Thanks in advance.</p>