progress bar in list activity
<p>please help me how can i put the progress bar in the following code . This code is basically fetching the list  from the server so what i want that before appearing the list from the server  progress bar should appear for the waiting time bcz it takes some time to fetch the list from the server </p>

<p>Here is the code </p>

<pre><code> public class Test extends ListActivity  {
          Prefs myprefs = null;

        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.listplaceholder);
            this.myprefs = new Prefs(getApplicationContext());
            ArrayList&lt;HashMap&lt;String, String&gt;&gt; mylist = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();

            JSONObject json = JSONfunctions.getJSONfromURL("http://midsweden.gofreeserve.com/fetch.php?id=" + 
                    Test.this.myprefs.getEmail());

            try{

                JSONArray  earthquakes = json.getJSONArray("earthquakes");

                for(int i=0;i&lt;earthquakes.length();i++){                        
                    HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();    
                    JSONObject e = earthquakes.getJSONObject(i);

                    map.put("id",  String.valueOf(i));
                    map.put("name", "Earthquake name:" + e.getString("name"));
                    map.put("password", "Magnitude: " +  e.getString("password"));
                    mylist.add(map);            
                }       
            }catch(JSONException e)        {
                 Log.e("log_tag", "Error parsing data "+e.toString());
            }

            ListAdapter adapter = new SimpleAdapter(this, mylist , R.layout.test, 
                            new String[] { "name", "magnitude" }, 
                            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(Test.this, "ID '" + o.get("id") + "' was clicked.", Toast.LENGTH_SHORT).show(); 

                }
            });
        }



        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            MenuInflater inflater = getMenuInflater();
            inflater.inflate(R.menu.menu, menu);
            return true;
        }

        @Override
        public boolean onOptionsItemSelected(MenuItem item) {
            switch (item.getItemId()) {
                case R.id.settings:     
                    Intent intent = new Intent(this, ShowSettings.class);
                      startActivity(intent);
                break;
                case R.id.services:     
                    Intent intent2 = new Intent(this, Test.class);
                    startActivity(intent2);
                  break;
                case R.id.Quit: 

                    finish();



                    break;
                default:    
                break;
            }
            return true;
        }
    }
</code></pre>
