title: Android how to update value of ProgressBar?
body: <p>My activity have a ProgressBar. When start activity, I'll check value get from another place and update to ProgressBar. Here's my code:</p>
  
  <pre><code>final ProgressBar progressBar = (ProgressBar) findViewById(R.id.progressBar_detail);
  final TextView progressText = (TextView) findViewById(R.id.progressText_detail);
  final ImageView btnCancel = (ImageView) findViewById(R.id.imgCancel_detail);
  progressBar.setVisibility(View.VISIBLE);
  progressText.setVisibility(View.VISIBLE);
  btnCancel.setVisibility(View.VISIBLE);
  Thread t = new Thread() {
      public void run() {
          ((Activity) ctx).runOnUiThread(new Runnable() {
              public void run() {
                  int oldProgress = 0;
                  while (progressBar.getProgress() &lt; 100) {
                      int value = Downloader.progress.get(gameId+ "");
                      if (value != oldProgress) {
                          oldProgress = value;
                          progressBar.setProgress(value);
                          progressText.setText(value + " %");
                      }
                  }
              }
          });
      }
  };
  t.start();
  </code></pre>
  
  <p>Value of ProgressBar i get from <code>int value = Downloader.progress.get(gameId)</code> and it's correct. But when I run this code, the activity is not responding and not showing anything (but app not crash). Seems like the thread to update ProgressBar running and block the UI thread so the activity layout is not showing.</p>
  
  <p>What's wrong with my code? What is the correct way to update ProgressBar in this situation?</p>