Forums Register Login
AsyncTask used to show progress bar
I wrote a program to show a progress bar using the AsyncTask class. I can see in the Log window the progress in increments of 5, but the progress bar does not show anything. The method showProgress() is activated by a button. Here is the MainActivity class:

And here's the layout file:

What is wrong? What is missing? (The Cancel button does not work either, but this is not my main concern now.) I want to see the progress bar animated. Thank you in advance for help! I really need it!
I haven't tested your code, but look at the documentation of setProgress method. It says Sets the progress for the progress bars in the title.. I guess you need to call setProgess method of ProgressBar class for your own progress bar declared in the xml file.

Hi Swastik, thank you for this idea. It almost works, using your suggestions. The only problem is that the bar does not fill up 100%. But I used your suggestion to pay attention to the setProgress function and I got it work!!!

Here's my program now:

Hi monica,

I tried with your last code, and for its me its filling the complete bar.
Yes, it does. That's what I meant to say. I just did not use exactly your code modification, but I got the idea from your code.
I did that in a hurry, any ways it's great that it worked.
To show increment near progress bar and not in logcat?
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards

This thread has been viewed 19588 times.

All times above are in ranch (not your local) time.
The current ranch time is
May 21, 2018 16:51:12.