title: Android - show progress dialog while doing work on UI thread
body: <p>I need to do some work on the UI thread, specifically setting up some views, etc. - this can't be done in a background thread.  The process is invoked on a button click and takes about a second or so to complete - without a progress dialog it looks as if the app is frozen.  I use progress dialog with <code>AsynTask</code>s in several places and it works fine - however here I'm struggling.</p>
  
  <p>I started with simple:</p>
  
  <pre><code>showDialog(DIALOG_PLEASE_WAIT);
  viewInfo.setFromGuide(true);          //this method just sets a variable
  viewInfo.setVenue(venue);             //this method does a lot of UI manipulation and takes a second or so
  showScreen(VIEW_INFO);                //this method shows the corresponding view in ViewFlipper
  dismissDialog(DIALOG_PLEASE_WAIT);
  </code></pre>
  
  <p>However the dialog would not show (sort of expected, as this is all on UI thread.</p>
  
  <p>Then I changed the code to this:</p>
  
  <pre><code>Handler hnd = new Handler() {
      @Override
      handleMessage(Message m) {
          viewInfo.setFromGuide(true);
          viewInfo.setVenue(venue);
          showScreen(VIEW_INFO);
          dismissDialog(DIALOG_PLEASE_WAIT);
      }
  }
  showDialog(DIALOG_PLEASE_WAIT);
  new Thread() {
      public void run() {
         hnd.sendEmptyMessage(0);
      }
  }.start();
  </code></pre>
  
  <p>This still doesn't show the dialog - naturally, the UI work in <code>handleMessage</code> is still done on the UI thread.  So, what can I do to show the progress dialog?</p>