title: How to use a ProgressBar?
body: <p>I have a search function (using a web service) which takes a while to load data to my inflated layout. I want to show a <code>ProgressBar</code> untill the data is fetched from the web service. This is a small time interval and hence I don't to use a <code>ProgressDialog</code> for this. I've gone through many posts and <em>dev</em> guide but I'm not able to figure out a way to use that in my app. I've a <code>Spinner</code> in my layout. Once I choose an item from the spinner drop down I pass the string to the search function which fetches as well as loads data into the inflated layout.</p>
  
  <pre><code>spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
  
      @Override
      public void onItemSelected(AdapterView&lt;?&gt; arg0, View arg1, int arg2,
              long arg3) {
          Selection = spinner.getSelectedItem().toString();           
  
          search(Selection);
      }
  </code></pre>
  
  <p>I created a ProgressBar, handler as explained in the <em>dev</em> guide. </p>
  
  <pre><code>private ProgressBar mProgress =  new ProgressBar(SearchActivity.this, null, android.R.attr.progressBarStyleSmall);
  private int mProgressStatus = 0;
  
  private Handler mHandler = new Handler();
  </code></pre>
  
  <p>And say this is a new thread used to display the <code>ProgressBar</code></p>
  
  <pre><code>new Thread(new Runnable() {
           public void run() {
               while (mProgressStatus &lt; 100) {
                   mProgressStatus = doWork();
  
                   // Update the progress bar
                   mHandler.post(new Runnable() {
                       public void run() {
                           mProgress.setProgress(mProgressStatus);
                       }
                   });
               }
           }
       }).start();
  </code></pre>
  
  <p>How do I track progress of my search function to show the <code>ProgressBar</code>? </p>
  
  <p>Thank you for reading</p>