Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8574405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:28:02+00:00 2026-06-11T19:28:02+00:00

i know this is a common question.. i read this site and many tutorial

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T19:28:03+00:00Added an answer on June 11, 2026 at 7:28 pm

    Well, I’ve only tested this solution with a very basic Button, but it worked, so here goes:

    You can do the creation and setup of the Views using an AsyncTask. I tried with a button, and any calls that modify/create a View work without problem in an AsyncTask, until you add the view to the layout. Once added, any modifications must be done on the UI thread. So all your setup will happen in doInBackground(), and all the addView() calls will be in onPostExecute(). After onPostExecute(), and more changes to the View will have to be done in an AsyncTask.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this is a very common question. But I've looked through SO and
I know this has probably been answered as it seems a common question but
I know this might be a common question but I have tried to search
First, I know this is kind of common question, but I could not find
I know this is a common question but I just can't seem to get
I know this may seem like a common question on SO but I could
I know this is a very common question, but I tried googling and got
I know this is a common question and there are oodles of resources on
i know this sounds really common and so trivial but , am having a
I know this is a common error, but bear with me. I've pursued the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.