开发者

how to Format an equation to update progressbar

开发者 https://www.devze.com 2023-03-20 23:46 出处:网络
Im trying to wrap my head around this but am spending too much time on it and cant find answers else where.

Im trying to wrap my head around this but am spending too much time on it and cant find answers else where. I have a progress bar that I need to update. I created a timer to hit a method every .1 seconds until the Data has downloaded. Then I will invalidate the timer. My question is.. how would I format an equation to update the progress bar. I already know what the total file size will be and it is in bytes. I believe the answer will be close to something like this but I just cant get it to work.

in开发者_JAVA百科t f = fileSize;  // I already know what filesize is going to be. for demo purposes lets say 19000000 bytes

float d = (z/10000000);

progressInt = (d * f);
progBar.progress = progressInt;

I think it something along those lines?? Any help would be greatly appreciated!


The progress is usually represented as a float between 0 and 1. bytesLoaded/filesize will be 0 when no bytes are loaded and 1 when it is fully loaded.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号