title: Android Progressbar showing/hiding while loading data
body: <p>I need help on this: Showing/hiding a progressbar while retrieving data from external source.</p>
  <p>I've got this progressbar declared in the activity layout resource file:</p>
  <pre><code>   &lt;ProgressBar
          android:id=&quot;@+id/progressBar2&quot;
          style=&quot;?android:attr/progressBarStyle&quot;
          android:layout_width=&quot;150dp&quot;
          android:layout_height=&quot;150dp&quot;
          android:layout_centerInParent=&quot;true&quot;/&gt;
  </code></pre>
  <p>In the onCreate activity method it is made invisible:</p>
  <pre><code>progressBar = (ProgressBar) findViewById(R.id.progressBar2);
  progressBar.setVisibility(View.INVISIBLE);
  </code></pre>
  <p>The before retrieving data from de server I show it -that is what I intent to do:</p>
  <pre><code>progressBar.setVisibility(View.VISIBLE);
  </code></pre>
  <p>Then when the data is retrieved, I intent to hide it again with:</p>
  <pre><code> progressBar.setVisibility(View.INVISIBLE);
  </code></pre>
  <p>But of course, not working as I pretend.
  What is wrong with the code or this approach to show a simple progressbar while the app is contacting the server for data?</p>