title: Progress Dialog should spin till loading of gridview completed
body: <p>I am working on one android app in which i want to display progress Dialog till loading of gridview completed. But my problem is progress dialog is spin for some intial time. Then it stops spinning. </p>
  
  <p>Here is my code.</p>
  
  <pre><code>public class allsites extends Activity {
  
      private final String url_select = "http://api.stackexchange.com/2.1/sites?filter=!RGB_Y51.*-(YX";
      private GridView gview;
      private ListViewCustomAdapter adapter;
      private ArrayList&lt;Object&gt; itemList = new ArrayList&lt;Object&gt;();
      private ItemBean bean;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          // TODO Auto-generated method stub
          super.onCreate(savedInstanceState);
          setContentView(R.layout.allsites);
          //GridView gridview = (GridView) findViewById(R.id.gvAllSites);
          gview = (GridView) findViewById(R.id.gvallsites);
          new task().execute();
  
  
      }
  
      private class task extends AsyncTask&lt;Void, Void, GZIPInputStream&gt; {
  
          private ProgressDialog progress;
  
  
          @Override
          protected void onPreExecute() {
  
              progress = ProgressDialog.show(allsites.this, "Loading", "Please Wait...");
          }
  
          @Override
          protected GZIPInputStream doInBackground(Void... params) {
  
              ServerData httpclient = new ServerData();
              GZIPInputStream zis = httpclient.GetServerData(url_select);
              return zis;
          }
  
          @Override
          protected void onPostExecute(GZIPInputStream zis) {
  
  
              ParseJSON(zis);
  
              if(progress!=null &amp;&amp; progress.isShowing()==true)
                  progress.dismiss();
  
  
  
          }
      }
  
      private void ParseJSON(GZIPInputStream zis)
      {
          Gson gson = new Gson();
  
          Reader reader = new InputStreamReader(zis);
  
          Sites response = gson.fromJson(reader, Sites.class);
  
          List&lt;Items&gt; items = response.getItems();
  
          for (Items site : items) {
              //Toast.makeText(allsites.this, site.getApi_site_parameter().toString(), Toast.LENGTH_SHORT).show();
               AddObjectToList(site.getIcon_url(),site.getName());
          }
  
          adapter = new ListViewCustomAdapter(this, itemList);
          gview.setAdapter(adapter);
      }
  
      public void AddObjectToList(String imageURL, String title)
      {
          bean = new ItemBean();
  
          try {
              Bitmap bitmap = BitmapFactory.decodeStream((InputStream)new URL(imageURL).getContent());
              bean.setImage(bitmap);
          } catch (MalformedURLException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
          bean.setTitle(title);
          itemList.add(bean);
      }
  
  }
  </code></pre>
  
  <p>Please give me suggestion how i can make progress dialog spinning till gridview get loaded.</p>