Android Progress Bars (Continuously Updating)
<p>The following code updates a set of progress bars when a button is clicked. (the values are random generated test values).</p>

<p>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.</p>

<p>I added a while loop to the onClick method but it causes the application to crash.</p>

<p>Does anyone know how can I implement this? Maybe I am missing something very simple?</p>

<p>Thanks in advance for any help!</p>

<pre><code>   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);

       }
   });
</code></pre>
