How to load listview in android with emply list and later the contents will download?
<p>I need to load load text in list but first it should load an empty list in that time it should display a progress bar. I fetch all the contents from the json feeder. But am stuck with how to load the empty list when the process is in backgroud.</p>

<pre><code>/**
 * This class loads MainScreen in ListView
 */
package com.smartmedia.salonaudi;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.app.ListActivity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import com.smartmedia.salonaudi.map.GoogleMapActivityClass;

/**
 * 
 * 
 * 
 */
public class SalonAudiActivity extends ListActivity {

    Button map;
    Button left;
    Button about;
    final Handler uiThreadCallback = new Handler();
    Runnable runInUIThread;
    // WebView about;

    ArrayList&lt;HashMap&lt;String, String&gt;&gt; mylist = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
    ArrayList&lt;HashMap&lt;String, String&gt;&gt; mylistCopy = mylist;
    ArrayList&lt;String&gt; latitude = new ArrayList&lt;String&gt;();
    ArrayList&lt;String&gt; longitude = new ArrayList&lt;String&gt;();

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.listplaceholder);
        //processDialog = ProgressDialog.show(this, "", getString(R.string.loading), true);
         // getDetails();
        // Map Button Click
        map = (Button) findViewById(R.id.seeonmap);

        map.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                Intent intent = new Intent(SalonAudiActivity.this,
                        GoogleMapActivityClass.class);


                intent.putExtra("latitude", latitude);
                intent.putExtra("longitude", longitude);
                startActivity(intent);
            }
        });

        // Live Button Click
        about = (Button) findViewById(R.id.about);

        about.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(Intent.ACTION_VIEW, Uri
                        .parse("http://google.com"));
                startActivity(intent);

            }
        });

        JSONObject json = JSONfunctions
                    .getJSONfromURL("http://audi.smart-media.no/api/getEvents.php");

            try {

                JSONObject es = json.getJSONObject("events");
                JSONArray event = es.getJSONArray("event");
                JSONObject[] events = new JSONObject[es.length()];

                for (int i = 0; i &lt; event.length(); i++) {

                    HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
                    JSONObject e = event.getJSONObject(i);
                    map.put("id", String.valueOf(i));
                    map.put("Time", "" + e.getString("startTime").split(" ")[0]);
                    map.put("startTime",
                            ""
                                    + e.getString("startTime").split(" ")[1]
                                            .substring(0, 5)
                                    + " @ Olympic Stadium");

                    map.put("title", "" + e.getString("title"));
                    System.out.println("title" + e.getString("title"));
                    map.put("ingress", "" + e.getString("ingress"));
                    map.put("description",
                            ""
                                    + e.getString("description").replaceAll(
                                            "\\&lt;[^&gt;]*&gt;", ""));
                    map.put("image", "" + e.getString("image"));
                    map.put("latitude", "" + e.getString("latitude"));
                    map.put("longitude", "" + e.getString("longitude"));

                    System.out.println("latitude" + e.getString("latitude"));
                    mylist.add(map);

                }

            }

            catch (JSONException e) {
                Log.e("log_tag", "Error parsing data " + e.toString());
            }



        ListAdapter adapter = new SimpleAdapter(this, mylist, R.layout.main,
                new String[] { "startTime", "title", "description" },
                new int[] { R.id.time, R.id.title, R.id.description });

        setListAdapter(adapter);

        final ListView lv = getListView();

        lv.setTextFilterEnabled(true);
        lv.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int arg2,
                    long arg3) {

                Intent intent = new Intent();
                intent.setClassName(SalonAudiActivity.this,
                        "com.smartmedia.salonaudi.DetailView");

                HashMap&lt;String, String&gt; map = mylistCopy.get(arg2);
                intent.putExtra("title", map.get("title"));
                intent.putExtra("image", map.get("image"));
                intent.putExtra("startTime", map.get("startTime"));
                intent.putExtra("ingress", map.get("ingress"));
                intent.putExtra("description", map.get("description"));
                startActivity(intent);
            }

        });

        for (int i = 0; i &lt; mylist.size(); i++) {
            HashMap&lt;String, String&gt; e = mylist.get(0);
            latitude.add(e.get("latitude"));
            longitude.add(e.get("longitude"));
        }
    }

    public boolean isConnected() {
        Context context = getApplicationContext();
        ConnectivityManager connectivity = (ConnectivityManager) context
                .getSystemService(Context.CONNECTIVITY_SERVICE);
        if (connectivity == null) {

        } else {
            NetworkInfo[] info = connectivity.getAllNetworkInfo();
            if (info != null) {
                for (int i = 0; i &lt; info.length; i++) {
                    if (info[i].getState() == NetworkInfo.State.CONNECTED) {
                        return true;
                    }
                }
            }
        }
        return false;
    }

}
</code></pre>
