i know this is a common question.. i read this site and many tutorial many many times but no chance to do work.

well the code is this:

```
public class mostraRisultatiActivity extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.mostra_risultati);

    int cnt = 0;
    final TableLayout tl = (TableLayout) findViewById(R.id.tabellaRisultati);

    for (Esame e : Db.risposteDate){
        TableRow tr = new TableRow(this);

        TextView lbl1 = new TextView(this);
        TextView lbl2 = new TextView(this);
        TextView lbl3 = new TextView(this);
        tr.setGravity(Gravity.CENTER);
        lbl1.setGravity(Gravity.CENTER_VERTICAL);
        lbl3.setGravity(Gravity.CENTER);

        lbl1.setTextColor(android.graphics.Color.RED);
        lbl2.setTextColor(android.graphics.Color.RED);
        lbl3.setTextColor(android.graphics.Color.RED);

        lbl1.setLayoutParams( new TableRow.LayoutParams( 0, android.view.ViewGroup.LayoutParams.WRAP_CONTENT, 1 ) );
        lbl2.setLayoutParams( new TableRow.LayoutParams( 0, android.view.ViewGroup.LayoutParams.WRAP_CONTENT, 7 ) );
        lbl3.setLayoutParams( new TableRow.LayoutParams( 0, android.view.ViewGroup.LayoutParams.WRAP_CONTENT, 1 ) );

        lbl1.setText(e.getDomandaNum()+"");
        lbl2.setText(Html.fromHtml(e.getTesto()+"<br />"));
        lbl3.setText(e.getRispostaData());

        tr.addView(lbl1);
        tr.addView(lbl2);
        tr.addView(lbl3);
        tl.addView(tr);
        if (e.getRispostaData() != null && e.getRispostaData().equals(e.getRispostaReale())){
            cnt++;
            lbl1.setTextColor(android.graphics.Color.GREEN);
            lbl2.setTextColor(android.graphics.Color.GREEN);
            lbl3.setTextColor(android.graphics.Color.GREEN);
        }
    }
    double percentualeSucceso = (cnt*100)/Db.risposteDate.size();

    final TextView risposteTotTV = (TextView) findViewById(R.id.risultatiTot);
    final TextView riassuntorisTV = (TextView) findViewById(R.id.risRiassunto);
    final TextView esitoTV = (TextView) findViewById(R.id.esito);

    risposteTotTV.setText(Html.fromHtml("<b><big>TOT</big></b>" +  "<br />" + 
            Db.risposteDate.size()));
    riassuntorisTV.setText(Html.fromHtml("<b>Risposte corrette: </b>" +cnt+  "<br />" + 
            "Percentuale: "+percentualeSucceso+"%"));
    if (percentualeSucceso >= 90) {
        esitoTV.setText(Html.fromHtml("<b><big>Esito</big></b>  <br />" + 
                                      "<small>PROMOSSO</small>"));
    } else {
        esitoTV.setText(Html.fromHtml("<b><big>Esito</big></b>  <br />" + 
                                      "<small>BOCCIATO</small>"));
    }

}

```

}

i want a progress bar while load the ui (in particulary the for loop)

i tried with a thread: all work but no progress show until the ui is loaded (useless)
i tried with asyncTask and i have always exception crash.

any idea?