title: Showing progress bar while loading a List
body: <p>Ok Now i admit that i am new to using progress bar infact i never use it but now i need to use it 
  I have an activity (Main) and a menu which can start 6 new activity. From these activities there is an activity which load the data in a ListView it take 3-4 second to load .This activity parse the json and pass the data to another activity. How can i show the progress bar as soon as user click the menu option for this activity and disappear it when List will be loaded.</p>
  
  <p>Here is the activiy </p>
  
  <pre><code>    public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
       final Intent intent=new Intent(this ,GetLatAndLng.class);
      setContentView(R.layout.listplaceholder);
      //ProgressBar pb=(ProgressBar)findViewById(R.id.progressbar);
      LocationManager locationManager;
      String context=Context.LOCATION_SERVICE;
      locationManager=(LocationManager)getSystemService(context);
  
      Criteria criteria = new Criteria();
      criteria.setAccuracy(Criteria.ACCURACY_FINE);
      criteria.setAltitudeRequired(false);
      criteria.setBearingRequired(false);
      criteria.setCostAllowed(true);
      criteria.setPowerRequirement(Criteria.POWER_LOW);
      String provider = locationManager.getBestProvider(criteria, true);
      Location location = locationManager.getLastKnownLocation(provider);
  
      final LocationListener locationListener = new LocationListener() {
          public void onLocationChanged(Location location) {
          updateWithNewLocation(location);
          }
          public void onProviderDisabled(String provider){
          updateWithNewLocation(null);
          }
          public void onProviderEnabled(String provider){ }
          public void onStatusChanged(String provider, int status,
          Bundle extras){ }
          };
      updateWithNewLocation(location);
      locationManager.requestLocationUpdates(provider, 2000, 10,
              locationListener);
      double geoLat = location.getLatitute();
      double geoLng = location.getLongitude();
           Bundle b=new Bundle();
      //pb.setVisibility(View.VISIBLE);
      ArrayList&lt;HashMap&lt;String, String&gt;&gt; mylist = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
  
      JSONObject json = JSONFunction.getJSONfromURL(getUrl());
      Log.v(TAG, "got the json"); 
      try{
          JSONArray  JArray = json.getJSONArray("results");
             Log.v(TAG, "getting results");
          for(int i=0;i&lt;JArray.length();i++){                     
              HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();    
              JSONObject e = JArray.getJSONObject(i);
              JSONObject location1=e.getJSONObject("geometry").getJSONObject("location");
              latitude[i]=location1.getDouble("lat");
              longitude[i]=location1.getDouble("lng");
              reference[i]=e.getString("reference");
              Log.v(TAG, reference[i]);
              distance[i]=GetLatAndLng.gps2m(geoLat, geoLng,latitude[i] ,longitude[i]); 
              map.put("id",  String.valueOf(i));
              map.put("name", "" + e.getString("name"));
              map.put("vicinity", "Address " +  e.getString("vicinity")+" "+"Disance:"+distance[i]);
  
              mylist.add(map);                
          }           
      }catch(JSONException e)        {
           Log.e("log_tag", "Error parsing data "+e.toString());
      }
  //   pb.setVisibility(View.GONE);
      b.putStringArray("key", reference);
      intent.putExtras(b);
      Log.v(TAG, ""+reference); 
      ListAdapter adapter = new SimpleAdapter(this, mylist , R.layout.listview, 
                      new String[] { "name", "vicinity", }, 
                      new int[] { R.id.item_title, R.id.item_subtitle });
  
      setListAdapter(adapter);
      final ListView lv = getListView();
      lv.setTextFilterEnabled(true);  
      lv.setOnItemClickListener(new OnItemClickListener() {
          public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {        
              @SuppressWarnings("unchecked")
              HashMap&lt;String, String&gt; o = (HashMap&lt;String, String&gt;) lv.getItemAtPosition(position);                   
             Toast.makeText(JsonExampleActivity.this, "ID '" + o.get("id") + "' was clicked.", Toast.LENGTH_SHORT).show();
              intent.putExtra("clickedid",position);
              startActivity(intent);
          }
      });
  }
  public void updateWithNewLocation(Location location2) {
      if(location2!=null) {
            double geoLat = location2.getLatitude();
              double geoLng = location2.getLongitude();
      }
  }
  </code></pre>
  
  <p>Thanks in Advance!!</p>