Android Progress Not Working Accordingly
Solution 1:
download image in using
publicclassLoginProgressextendsAsyncTask<Object, Object, Object> {
privateProgressDialog dialog;
@OverrideprotectedvoidonPreExecute() {
this.dialog = ProgressDialog.show(applicationContext, "Please wait down",
"Loading .....", true);
}
@OverrideprotectedObjectdoInBackground(Object... params) {
// TODO Auto-generated method stubreturnnull;
}
@OverrideprotectedvoidonPostExecute(Void unused) {
//Intent for next activitythis.dialog.dismiss();
}
}
create object for these class in button click
LoginProgresstask=newLoginProgress();
task.execute();
call ur doinbackground method in these doinbackground methode
otherwise do following two
increment time of Thread.sleep(1000); change to Thread.sleep(4000); Thread.sleep(200); change to Thread.sleep(450);
you set gridview.setAdapter(new URLImageAdapter(CacheActivity.this)); in oncreate , remove this adapter in oncreate and write it in end of on click method...
Solution 2:
The problem is that you don't pass any values to publishProgress()
of your LoadThumbsTask
Pass some value to this method (e.g. number of already downloaded thumbs), and then in onProgressUpdate()
update your ProgressDialog
based on this value.
Solution 3:
public int doInBackground() {
while (fileSize <= 1000000) {
fileSize++;
if (fileSize == 100000) {
return10;
} elseif (fileSize == 200000) {
return20;
} elseif (fileSize == 300000) {
return30;
}elseif (fileSize == 400000) {
return40;
}elseif (fileSize == 500000) {
return50;
}elseif (fileSize == 600000) {
return60;
}elseif (fileSize == 700000) {
return70;
}elseif (fileSize == 800000) {
return80;
}elseif (fileSize == 900000) {
return90;
}
}
return100;
}
it's not tied to the actual file size. it should be something like
return (currentFilesize/totalFilesize)*100
and not just raw values like these.
Solution 4:
As per my experience, Progressbar has refresh issue when It's inside listview or gridview, If you only want to indicate progress I suggest to develop your own control which looks like progressbar with RelativeLayout.
Take relativelayout and add imageview in that. and increase width of imageview to illustrate like progress.
I can post code if you wish, I have develop one such progress for myself
UPDATE : I found good post for that same, Following post indicate same technique which I describe.
http://blog.mediarain.com/2011/04/android-custom-progressbar-with-rounded-corners/
Demo Downloadable : http://blog.mediarain.com/wp-content/uploads/2011/04/RoundedProgressSample.zip
Post a Comment for "Android Progress Not Working Accordingly"