I tried to build a progress bar in android, as you know progress bar get int for progress, but I need to pass float to progress bar, what can I do?
private Runnable myThread = new Runnable(){
@Override
public void run() {
mypb = mypb + 100 / time;
pb.setProgress(mypb);
}
};
You probably have it solved by now, but my workaround to this is multiplying by 10 or 100, depending on the number of decimals.
If your value is, 30.59 and your max is 100, then just multiply both values by 100. Which will give you 3059 and 10000.
setProgress() doesn't have float argument. So you can not set float value.
but you can cast your float value to int by-
pb.setProgress((int)mypb);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With