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

  • SEARCH
  • Home
  • 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 6864989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:59:02+00:00 2026-05-27T02:59:02+00:00

The following code updates a set of progress bars when a button is clicked.

  • 0

The following code updates a set of progress bars when a button is clicked. (the values are random generated test values).

For testing purposes I would ideally like the progress bars to be continuously updating. i.e. the button is pushed and the progress bars update, wait a second or two and update again and so on.

I added a while loop to the onClick method but it causes the application to crash.

Does anyone know how can I implement this? Maybe I am missing something very simple?

Thanks in advance for any help!

   Button dtTest = (Button) findViewById(R.id.button1);
   dtTest.setOnClickListener(new View.OnClickListener() {
       public void onClick(View view) {

                    // Generate Data Table
                    int pb1 = (int)(Math.random()*100);
                    int pb2 = (int)(Math.random()*100);
                    int pb3 = (int)(Math.random()*100);
                    int pb4 = (int)(Math.random()*100);

                    ProgressBar pbFeedPump = (ProgressBar) findViewById(R.id.progressBar1);
                    ProgressBar pbMediaFilter = (ProgressBar) findViewById(R.id.progressBar2);
                    ProgressBar pbCartridges = (ProgressBar) findViewById(R.id.progressBar3);
                    ProgressBar pbMotor = (ProgressBar) findViewById(R.id.progressBar4);

                    // Update Progress Bars
                    pbFeedPump.setProgress(pb1);
                    pbMediaFilter.setProgress(pb2);
                    pbCartridges.setProgress(pb3);
                    pbMotor.setProgress(pb4);

       }
   });
  • 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-05-27T02:59:03+00:00Added an answer on May 27, 2026 at 2:59 am

    Easiest way is to use a Timer, especially one of the scheduleAtFixedRate overloads.

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

Sidebar

Related Questions

I have the following code: UPDATE myTable SET Col1 = @Value However, I have
The following code works on insert but on update modifier is never set, any
I have the following code: $updateCode = mysql_query(UPDATE pages SET pageCode='$code' WHERE id='$userID' AND
The following statement updates a column in a table named 'test'. UPDATE test AS
I'm running the following code to update the database according to the data I
I'm using the following code to update a DataGridView's cell value. This is called
Looking through some code I came across the following code trTuDocPackTypdBd.update(TrTuDocPackTypeDto.class.cast(packDto)); and I'd like
the following code (from a database object created for each new view): -(void)update:(NSString *)queryText{
I have the following javascript code, which loads without error, however the update function
Following code, when compiled and run with g++, prints '1' twice, whereas I expect

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.