title: Loading Progress Bar android
body: <p>*I have class which load some files and update the UI...It takes some times to view the result,... So I want to add a loading bar or progress bar. Some data has been passed by other activity(Bundle extras1 = getIntent().getExtras();). But I am downloading one image per item... I think that takes more time. Any one can help me?</p>
  
  <p>This is my code:</p>
  
  <pre><code>public class ShowSelectedEvents extends Activity {
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.viewdetailsevents);
      Bundle extras1 = getIntent().getExtras();
      String eventTitle = extras1.getString("eventTitle");
      final String address = extras1.getString("address");
      String date = extras1.getString("date");
      String time = extras1.getString("time");
      final String fix = extras1.getString("fix");
      final String mobile = extras1.getString("mobile");
      final String web = extras1.getString("web");
      final String mail = extras1.getString("mail");
      String imageLink = extras1.getString("imageLink");
      final String videoLink = extras1.getString("videoLink");
      // Add item image
      Bitmap bitMap = null;
      try {
          bitMap = DownloadImage("imageLink);
      } catch (Exception e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
      ImageView imageItem = (ImageView) findViewById(R.id.imageItem);
      imageItem.setImageBitmap(bitMap);
      TextView viewTitle = (TextView) findViewById(R.id.viewTitle);
      viewTitle.setText(eventTitle);
      TextView viewDateTime = (TextView) findViewById(R.id.dateTime);
      viewDateTime.setText("Event is on "+date +" @ "+ time);
      // View Address
      TextView viewAdd = (TextView) findViewById(R.id.viewAddress);   
      viewAdd.setTypeface(Typeface.defaultFromStyle(Typeface.ITALIC),Typeface.ITALIC);
      viewAdd.setText(address);
      // On click open Navigation
      if (!(address.equals("-"))){
          ImageView navigationIcon = (ImageView) findViewById(R.id.imageMapNavigation);
          navigationIcon.setOnClickListener(new OnClickListener() {           
              @Override
              public void onClick(View v) {
                  String url = "google.navigation:q="+address;
                  Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url));            
                  startActivity(i);
              }
          }); 
      }else{
          Context context = getApplicationContext();
          CharSequence text = "Address is incomplete!";
          int duration = Toast.LENGTH_SHORT;
          Toast toast = Toast.makeText(context, text, duration);
          toast.show();
      }
      // View Phone number
      TextView viewPhoneNumber = (TextView) findViewById(R.id.viewPhoneNumber);
      viewPhoneNumber.setTypeface(Typeface.defaultFromStyle(Typeface.ITALIC),Typeface.ITALIC);
      viewPhoneNumber.setText(fix);
      // On click open call 
      if (!(fix.equals("-"))){
          viewPhoneNumber.setOnClickListener(new OnClickListener() {
              @Override
              public void onClick(View v) {
                  String url = "tel:"+fix;
                  Intent i = new Intent(Intent.ACTION_CALL, Uri.parse(url));  
                  startActivity(i);
              }
          });
      }
      //View Mobile number
      TextView viewMobileNumber = (TextView) findViewById(R.id.viewMobileNumber);
      viewMobileNumber.setTypeface(Typeface.defaultFromStyle(Typeface.ITALIC),Typeface.ITALIC);
      viewMobileNumber.setText(mobile);
      // on click call mobile number
      if (!(mobile.equals("-"))){
          viewMobileNumber.setOnClickListener(new OnClickListener() {
              @Override
              public void onClick(View v) {
                  String url = "tel:"+mobile;
                  Intent i = new Intent(Intent.ACTION_CALL, Uri.parse(url));  
                  startActivity(i);
              }
          });
      }
      //View web url
      TextView viewWeb = (TextView) findViewById(R.id.viewWeb);
      viewWeb.setTypeface(Typeface.defaultFromStyle(Typeface.ITALIC),Typeface.ITALIC);
      viewWeb.setText(web);
      //on click open web browser
      if (!(web.equals("-"))){
          viewWeb.setOnClickListener(new OnClickListener() {
              @Override
              public void onClick(View v) {
                  Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(web));
                  startActivity(i);
              }
          });
      }
      TextView viewMail = (TextView) findViewById(R.id.viewMailAddress);
      viewMail.setTypeface(Typeface.defaultFromStyle(Typeface.ITALIC),Typeface.ITALIC);
      viewMail.setText(mail);
      if(!(mail.equals("-"))){
          viewMail.setOnClickListener(new OnClickListener() {
              @Override
              public void onClick(View v) {
                  Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
                  emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] {mail});
                  emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Contact from tamilpage.ch");
                  emailIntent.setType("text/plain");
                  startActivity(Intent.createChooser(emailIntent, "Send a mail ..."));
              }
          });
      }
      // On click play the video
      if (!(address.equals("-"))){
          ImageView videoIcon = (ImageView) findViewById(R.id.videoButton);
          videoIcon.setOnClickListener(new OnClickListener() {            
              @Override
              public void onClick(View v) {
                  Intent browserIntent = new Intent(Intent.ACTION_VIEW,
                          Uri.parse(videoLink));
                  startActivity(browserIntent);
              }
          }); 
      }else{
          Context context = getApplicationContext();
          CharSequence text = "No advert video for this event";
          int duration = Toast.LENGTH_SHORT;
          Toast toast = Toast.makeText(context, text, duration);
          toast.show();
      }
  }
  private Bitmap DownloadImage(String url) throws Exception {
      Bitmap bitmap = null;
      InputStream in = null;
      try {
          in = OpenHttpConnection(url);
          bitmap = BitmapFactory.decodeStream(in);
          in.close();
      } catch (IOException e1) {
          e1.printStackTrace();
      }
      return bitmap;
  }
  private InputStream OpenHttpConnection(String url) throws Exception {
      InputStream in = null;
      int response = -1;
      System.out.println("Nishi1"); 
      URL url1 = new URL(url); 
      URLConnection conn = url1.openConnection();
      if (!(conn instanceof HttpURLConnection)) 
          throw new IOException("Not an HTTP connection");
      try{
          HttpURLConnection httpConn = (HttpURLConnection) conn;
          httpConn.setAllowUserInteraction(false);
          httpConn.setInstanceFollowRedirects(true);
          httpConn.setRequestMethod("GET");
          httpConn.connect(); 
          response = httpConn.getResponseCode(); 
          if (response == HttpURLConnection.HTTP_OK) {
              in = httpConn.getInputStream(); 
              System.out.println(in);
          } 
      }
      catch (Exception ex)
      {
          throw new IOException("Error connecting"); 
      }
      return in; 
  }
  </code></pre>
  
  <p>}</p>