title: Android - using runOnUiThread to do UI changes from a thread
body: <p>I am using a custom title view and would like to show/hide a progressbar in the title view when a thread is working.</p>
  
  <p>This is my title view's XML</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="horizontal"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
  &gt;
      &lt;Button
          android:id="@+id/image_left_btn"
          android:layout_width="75dip" 
          android:layout_height="wrap_content" 
          android:text="Back"
      /&gt;
      &lt;TextView
          android:id="@+id/image_title_text"
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_weight="1"
          android:textSize="20dip"
          android:textStyle="bold"
          android:textColor="#fff"
          android:layout_gravity="center"
          android:gravity="center"
          android:paddingLeft="8dip"
          android:paddingRight="8dip"
      /&gt;
      &lt;ProgressBar 
          android:id="@+android:id/progress_small_title"
          style="?android:attr/progressBarStyleSmall"
          android:layout_width="75dip"
          android:layout_height="wrap_content" 
          android:paddingRight="8dip"/&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>In my Activity, after setting this as the custom title bar, I do this</p>
  
  <pre><code>titleProgress = (ProgressBar)findViewById(R.id.progress_small_title);
  titleProgress.setVisibility(View.INVISIBLE);
  </code></pre>
  
  <p>where titleProgress is ProgressBar object.</p>
  
  <p>This is what I do in my thread</p>
  
  <pre><code>runOnUiThread(new Runnable() {
      public void run() {
          titleProgress.setVisibility(View.VISIBLE);
      }
  });
  //long operation here
  runOnUiThread(new Runnable() {
      public void run() {
          titleProgress.setVisibility(View.INVISIBLE);
      }
  });
  </code></pre>
  
  <p>But there is no change to the progress bar. It is never displayed. Can someone please tell me what is wrong with the code?</p>
  
  <p>Is it possible to display the title progressbar in a custom title?</p>
  
  <p>Thanks.</p>