title: Android show progress bar while image loading dynamically
body: <p>In one of my project, I am loading images from the dynamic url. Now I need to show the loading dialogue still all the images loads. I am loading the images using the Async task.
  I am new to android. Please any one give me a little help </p>
  
  <p>My code looks like.</p>
  
  <pre><code>TableLayout table = (TableLayout)findViewById(R.id.tableLayout_1);
          for(Integer i=0;i&lt;2;i++){
  
  
              TableRow rowP = new TableRow(this);
              rowP.setBackgroundColor(Color.parseColor("#FFF000"));
  
  
  
  
              ImageView image = new ImageView(this);
              String ed="http://www.domain.com/image.jpg";
              image.setTag(ed);
              DownloadImagesTask td=new DownloadImagesTask();
              td.execute(image);
  
              rowP.addView(image);
              table.addView(rowP);
              }
          }
  
  
  private class DownloadImagesTask extends AsyncTask&lt;ImageView, Void, Bitmap&gt; {
  
      ImageView imageView = null;
  
      @Override
      protected Bitmap doInBackground(ImageView... imageViews) {
          this.imageView = imageViews[0];
          return download_Image((String)imageView.getTag());
      }
  
      @Override
      protected void onPostExecute(Bitmap result) {
          imageView.setImageBitmap(result);
      }
  
      private Bitmap download_Image(String url) {
  
          Bitmap bmp =null;
          try{
              URL ulrn = new URL(url);
              HttpURLConnection con = (HttpURLConnection)ulrn.openConnection();
              InputStream is = con.getInputStream();
              bmp = BitmapFactory.decodeStream(is);
              if (null != bmp)
                  return bmp;
  
              }catch(Exception e){}
          return bmp;
      }
  }
  </code></pre>
  
  <p>Thanks in advance</p>
  
  <p><strong>Edit</strong> </p>
  
  <pre><code>private class DownloadImagesTask extends AsyncTask&lt;ImageView, Void, Bitmap&gt; {
  
          ImageView imageView = null;
          ProgressDialog dialog;
          Context context;
  
          public DownloadImagesTask(Context context) {
              this.context = context;
          }
  
          @Override
          protected Bitmap doInBackground(ImageView... imageViews) {
              this.imageView = imageViews[0];
              return download_Image((String)imageView.getTag());
          }
  
          @Override
          protected void onPostExecute(Bitmap result) {
              imageView.setImageBitmap(result);
              if (dialog != null)
                  dialog.dismiss();
          }
  
          @Override
          protected void onPreExecute() {
              super.onPreExecute();
              dialog = ProgressDialog.show(context, "Title","Message");
          }
  
          private Bitmap download_Image(String url) {
  
              Bitmap bmp =null;
              try{
                  URL ulrn = new URL(url);
                  HttpURLConnection con = (HttpURLConnection)ulrn.openConnection();
                  InputStream is = con.getInputStream();
                  bmp = BitmapFactory.decodeStream(is);
                  if (null != bmp)
                      return bmp;
  
                  }catch(Exception e){}
              return bmp;
          }
      }
  </code></pre>