title: ProgressBar while loading ListView (using AsyncTask)
body: <p>I'm trying to show a progress bar when loading a custom ListView and afterwards - hide it.
  I'm using ASync task, but for some reason - The content view is not set and the previous layout view is stuck until all the list view is loaded.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>private ListView listViewGameResults;   
      protected View dialogLayout;
      protected ArrayList&lt;Game&gt; listGames;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState); 
          setContentView(R.layout.adresults);
          GameResultsLoader gameResultsLoader = new GameResultsLoader();              
          gameResultsLoader.execute();        
      }
  
      private class GameResultsLoader extends AsyncTask&lt;Void, Void, Void&gt; {       
          private GameResultsAdapter adapter;
  
          public GameResultsLoader() {            
          }
  
          @Override
          protected void onPreExecute() { 
          }
  
          @Override
          protected Void doInBackground(Void... params) { 
              try {
              listGames = GameResultsCache.getInstance().getGameResults();
              adapter = new GameResultsAdapter(getBaseContext(), listGames);
              listViewGameResults = (ListView)findViewById(R.id.listViewGameResults);
              } 
              catch (Exception e) {
                  // TODO Auto-generated catch block
                  finish();
              }
  
              return null;
          }
  
          @Override
          protected void onPostExecute(Void res) {
              listViewGameResults.setAdapter(adapter);
              listViewGameResults.setDivider(null);
              listViewGameResults.setDividerHeight(0);
              ProgressBar pb = (ProgressBar)findViewById(R.id.progressbar_loading);
              pb.setVisibility(View.GONE);            
          }
      }
  </code></pre>
  
  <p>ProgressBar and ListView in my layout:</p>
  
  <pre><code>&lt;ProgressBar
         style="?android:attr/progressBarStyle"
         android:layout_centerInParent="true"
         android:id="@+id/progressbar_loading"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content" /&gt;
      &lt;ListView
           android:id="@+id/listViewGameResults"
           android:layout_width="fill_parent"
           android:layout_height="fill_parent"
           android:layout_marginTop="1dip"
           android:layout_below="@+id/upperstrip"
           android:layout_above="@+id/ivDownStrip" /&gt;
  </code></pre>