Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMahmoud Tokura
789 PointsHow do i set INDETERMINATE_PROGRESS
How do i set INDETERMINATE_PROGRESS for this activity in case of slow network so the user knows something is happening. If the network is slow to retrieve, the user might thing the app has crashed or the phone has frozen.
I need to set INDETERMINATE_PROGRESS.
1 Answer
Daniel Hartin
18,106 PointsHi Mahmoud
What i have done in my apps for network connections that require some form of data returned is set the xml layout file to be a relativeLayout and then place a progress bar at the end of the xml file which covers the entire screen, then you can simply refer to this this in your activity like you would any other view and set it by doing something like
ProgressBar mProgressBar = (ProgressBar) findViewById(R.id.progressbar1);
mProgressBar.setVisibility(View.VISIBLE); //To turn on
mProgressBar.setVisibility(View.INVISIBLE); to turn off
The reason I would use a progressBar that covers the screen is that I assume as your are recovering images (guessing based on question) the user can't really continue until the images are found so a small progress bar in the notification bar may be missed. If you definitely want it in the notification bar however use the following
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); //put this before the call to setContentView()
setSupportProgressBarIndeterminateVisibility(true); //to turn on
setSupportProgressBarIndeterminateVisibility(false); //to turn off
Obviously for both of the above you have to turn them on and off manually when you start you aSyncTask and when the data is returned.
Hope this helps
Daniel
Mahmoud Tokura
789 PointsMahmoud Tokura
789 PointsHi Daniel Hartin
Thanks for your reply, i will try it.