You need to update your progress bar in a separate thread to the the
main (UI) one, see the example here:

http://developer.android.com/reference/android/widget/ProgressBar.html

What you have is saying "When creating the activity, loop 1000 times
and change the progress bar position value each time. Then display the
activity (including progress bar) to the user."


On Tue, Sep 1, 2009 at 11:51 AM, jbrohan<[email protected]> wrote:
>
> Hello
> I've been having some difficulties with  the progress bar. I built a
> separate test harness and now I start to see things more clearly. The
> code below seems to work correctly, but updates the progress bar only
> when it finishes. I want it to update as the progress is made!
>
> package com.example.progressbartest;
> <snip imports>
>
> public class ProgressBarTest extends Activity {
>        static int i;
>    /** Called when the activity is first created. */
>   �...@override
>    public void onCreate(Bundle savedInstanceState) {
>        super.onCreate(savedInstanceState);
>        // Request the progress bar to be shown in the title
>        requestWindowFeature(Window.FEATURE_PROGRESS);
>        setContentView(R.layout.main);
>        setProgressBarVisibility(true);
>
>        final ProgressBar progressHorizontal = (ProgressBar)
> findViewById(R.id.progress_horizontal);
>        while (i<1000){
>                setProgress(i++);
>                Log.e("John","in loop"+Integer.toString(i));
>              }
>    }
>   }
>
> There are actually two progress bars, like in the API demo app. One in
> the title bar and another in the main screen. One would be sufficient,
> but I don't know (yet) how to get rid of just one!
>
> John
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to