Main.xml not loading when a loop of any sort introduced in Android code
<p>Please refer to the following code, which grabs some information from a PHP script, and displays it on my phone:</p>

<pre><code>package room.temperature;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

public class RoomTemperatureActivity extends Activity {

    String result = null;
    StringBuilder sb=null;

    TextView TemperatureText, DateText;
    ArrayList&lt;NameValuePair&gt; nameValuePairs;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        TemperatureText = (TextView) findViewById(R.id.temperature); 
        DateText = (TextView) findViewById(R.id.date); 
        nameValuePairs = new ArrayList&lt;NameValuePair&gt;();
    }

    @Override
    public void onResume() {
        super.onResume();
        //setValues();

        for (int i = 0; i &lt; 10; i++) {
            setValues();
        }
    }

    public void setValues() {

        InputStream is = null;

        try {
            HttpClient httpclient = new DefaultHttpClient();
            HttpPost httppost = new HttpPost("http://mywebsite.com/tempscript.php");
            httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
            HttpResponse response = httpclient.execute(httppost);
            HttpEntity entity = response.getEntity();
            is = entity.getContent();
        }

        catch(Exception e)  {
            Log.e("log_tag", "Error in http connection" + e.toString());
        }

        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),8);
            sb = new StringBuilder();
            sb.append(reader.readLine());
            is.close();
            result=sb.toString();
        }

        catch(Exception e)  {
            Log.e("log_tag", "Error converting result " + e.toString());
        }

        System.out.println(result);

        String[] values = result.split("&amp;");

        TemperatureText.setText(values[0]);
        DateText.setText(values[1]);

    }
}
</code></pre>

<p>This code works great when I comment out the for-loop, and just call <code>setValues()</code> once. However, as soon as I introduce the loop, <code>main.xml</code> (or anything on the screen) does not load until the loop is complete. I thought it had something to do with the activity life cycle, but no matter where I have tried putting my code, it simply is not working right. Essentially, I want the values to keep updating every time I call <code>setValues()</code>. A 10 iteration loop is just for testing the concept.</p>
