Progress Bar during the loading of a ListView <p>So, I want to display a spinning loading indicator while my ListView is being populated. I successfully have implemented the progress bar, BUT for some reason it disappears BEFORE all of the listings are displayed. What I want is the progressbar to be present during the TOTAL load time of the listings. Basically, what it seems like, each listing is being displayed one at a time, not all at once when they are all loaded. What I'm doing is 1. Creating a new custom adapter class 2. Populating the ListView in an AsyncTask using this adapter class 3. Setting the ListView to this adapter</p> <p>This works properly, the progress bar just disappears before all of the listings are displayed. Does anyone have any ideas?</p> <p>Activity class:</p> <pre><code>public class MainActivity extends ActionBarActivity { ArrayList&lt;Location&gt; arrayOfLocations; LocationAdapter adapter; // public static Bitmap bitmap; Button refresh; ProgressBar progress; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); progress=(ProgressBar)findViewById(R.id.progressbar_loading); // Construct the data source arrayOfLocations = new ArrayList&lt;Location&gt;(); // Create the adapter to convert the array to views adapter = new LocationAdapter(this, arrayOfLocations); FillLocations myFill = new FillLocations(); myFill.execute(); refresh = (Button) findViewById(R.id.refresh); refresh.setOnClickListener(new OnClickListener() { public void onClick(View v) { finish(); startActivity(getIntent()); } }); } private class FillLocations extends AsyncTask&lt;Integer, Void, String&gt; { String msg = "Done"; protected void onPreExecute() { progress.setVisibility(View.VISIBLE); } // Decode image in background. @Override protected String doInBackground(Integer... params) { String result = ""; InputStream isr = null; try { HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("http://afs.spotcontent.com/"); // YOUR // PHP // SCRIPT // ADDRESS HttpResponse response = httpclient.execute(httppost); HttpEntity entity = response.getEntity(); isr = entity.getContent(); // resultView.setText("connected"); } catch (Exception e) { Log.e("log_tag", "Error in http connection " + e.toString()); } // convert response to string try { BufferedReader reader = new BufferedReader( new InputStreamReader(isr, "iso-8859-1"), 8); StringBuilder sb = new StringBuilder(); String line = null; while ((line = reader.readLine()) != null) { sb.append(line + "\n"); } isr.close(); result = sb.toString(); } catch (Exception e) { Log.e("log_tag", "Error converting result " + e.toString()); } // parse json data try { JSONArray jArray = new JSONArray(result); for (int i = 0; i &lt; jArray.length(); i++) { final JSONObject json = jArray.getJSONObject(i); try { BitmapWorkerTask myTask = new BitmapWorkerTask( json.getInt("ID"), json); myTask.execute(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } catch (Exception e) { // TODO: handle exception Log.e("log_tag", "Error Parsing Data " + e.toString()); } return msg; } protected void onPostExecute(String msg) { // Attach the adapter to a ListView ListView listView = (ListView) findViewById(R.id.listView1); // View header = (View) getLayoutInflater().inflate( // R.layout.listview_header, null); // listView.addHeaderView(header); listView.setAdapter(adapter); progress.setVisibility(View.GONE); } } } </code></pre> <p>Adapter class:</p> <pre><code>public class LocationAdapter extends ArrayAdapter&lt;Location&gt; { public LocationAdapter(Context context, ArrayList&lt;Location&gt; locations) { super(context, R.layout.item_location, locations); } @Override public View getView(int position, View convertView, ViewGroup parent) { // Get the data item for this position Location location = getItem(position); // Check if an existing view is being reused, otherwise inflate the view if (convertView == null) { convertView = LayoutInflater.from(getContext()).inflate(R.layout.item_location, parent, false); } // Lookup view for data population TextView tvName = (TextView) convertView.findViewById(R.id.tvName); TextView tvDetails = (TextView) convertView.findViewById(R.id.tvDetails); TextView tvDistance = (TextView) convertView.findViewById(R.id.tvDistance); TextView tvHours = (TextView) convertView.findViewById(R.id.tvHours); ImageView ivIcon = (ImageView) convertView.findViewById(R.id.imgIcon); // Populate the data into the template view using the data object tvName.setText(location.name); tvDetails.setText(location.details); tvDistance.setText(location.distance); tvHours.setText(location.hours); ivIcon.setImageBitmap(location.icon); // Return the completed view to render on screen return convertView; } } </code></pre>