title: Show progressDialog before load XML file
body: <p>I use the following code, to open a XML file and view its info in a ListView.<br>
  I have included a ProgressDialog in the first part of my code, in order to show it until files loading and once they are loaded the ProgressDialog disappears.<br>
  The problem is that ProgressDialog is being shown when files are already loaded. The screen is black till files are being loaded and when they are completely loaded, ListView is being displayed and at the same time ProgressDialog displays.<br>
  Please help me.<br>
  Thanks</p>
  
  <pre><code>public class Main extends ListActivity {
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
  
      super.onCreate(savedInstanceState);
  
      final ProgressDialog _progressDialog = new ProgressDialog(this);
      _progressDialog.setIcon(R.drawable.icon);
      _progressDialog.setTitle("Loading ...");
      _progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
  
      runOnUiThread(new Runnable() {
  
          @Override
          public void run() {
              _progressDialog.show();
               Thread t = new Thread() {
                    public void run(){
                        GetData();
                        _progressDialog.dismiss();
                      }
                    };
                    t.run();
          }
      });
  
  }
  
  public boolean GetData() {
  
      ArrayList&lt;HashMap&lt;String, String&gt;&gt; mylist = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
  
      setContentView(R.layout.listplaceholder);
  
      String xml = XMLfunctions.getXML();
      Document doc = XMLfunctions.XMLfromString(xml);
  
      int numResults = XMLfunctions.numResults(doc);
  
      if((numResults &lt;= 0)){
          Toast.makeText(Main.this, "Geen resultaten gevonden", Toast.LENGTH_LONG).show();  
          finish();
      }
  
      NodeList nodes = doc.getElementsByTagName("result");
  
      for (int i = 0; i &lt; nodes.getLength(); i++) {                           
          HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();    
  
          Element e = (Element)nodes.item(i);
          map.put("id", XMLfunctions.getValue(e, "id"));
          map.put("name", "Naam:" + XMLfunctions.getValue(e, "name"));
          map.put("Score", "Score: " + XMLfunctions.getValue(e, "score"));
          mylist.add(map);            
      }       
  
      ListAdapter adapter = new SimpleAdapter(this, mylist , R.layout.main, 
                      new String[] { "name", "Score", "name" }, 
                      new int[] { R.id.item_title, R.id.item_subtitle, R.id.item_subtitle2 });
  
      setListAdapter(adapter);
  
      final ListView lv = getListView();
      lv.setTextFilterEnabled(true);  
      lv.setOnItemClickListener(new OnItemClickListener() {
          public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {              
              @SuppressWarnings("unchecked")
              HashMap&lt;String, String&gt; o = (HashMap&lt;String, String&gt;) lv.getItemAtPosition(position);                   
              Toast.makeText(Main.this, "ID '" + o.get("name") + "' was clicked.", Toast.LENGTH_LONG).show(); 
  
          }
      });
  
      return true;
  }
  }
  </code></pre>