Friday, July 19, 2013

[android help] AsyncTask with a ProgressDialog and Progress Bar


AsyncTask with a ProgressDialog and Progress Bar



I am attempting to use AsyncTask to load a file of determinate length. My AsyncTask looks something like this:



protected void onPreExecute() {
dialog = ProgressDialog.show(MyActivity.this, null, "Loading", false);
}


protected void onProgressUpdate(Integer... values) {
if (values.length == 2) {
dialog.setProgress(values[0]);
dialog.setMax(values[1]);
}
}


in my doInBackground() implementation I call publishProgress(bytesSoFar, maxBytes); inside my loading loop and in the onPostExecute() I call dialog.dismiss().


However, I can't get the ProgressDialog to show anything but an indeterminate spinner. I want to see a horizontal progress bar that shows the progress as the loading happens. I've debugged and can see that onProgressUpdate() gets called with sane values and that the dialog's methods are getting called.



Read more

stackoverflow.comm



No comments:

Post a Comment

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...