改变进度条为双 [英] change progress bar into double
问题描述
进度条:
ProgressBar pb = (ProgressBar) findViewById(R.id.progressbar);
pb.setProgress(0);
int k = (int)max;
pb.setMax(k);
int j = (int)(cost);
pb.setProgress(j);
这code的进度条,只需要我想改变code采取双重价值int值
this code for a progress bar that only take an int value i want to change the code to take a double value
推荐答案
您不能。在进度
部件只接受整数
其最大和目前的进展。你无法控制的最低,因为它始终是 0
。
You can't. The ProgressBar
widget only accepts ints
for its max and current progress. You can't control the minimum, as it is always 0
.
您可以用10的幂,使得小数消失乘以你需要的最大和目前的进展值。在进度
仍将显示进度相同数量,因为它会用十进制值,因为进步是 CurrentValue的/ maxValue(最大值)$的比例C $ C>。正如你将用同样数量乘以两者的比例是相等的。例如:
You could multiply your required maximum and current progress values by a power of 10, such that the decimal goes away. The ProgressBar
will still show the same amount of progress as it would with a decimal value, as the progress is a ratio of currentValue/maxValue
. As you'll be multiplying both by the same number, the ratios are equal. For example:
0.1/10 = 0.01
然而,如果你无论多在0.1和10×10摆脱了小数,你就会得到:
However, if you multiple both 0.1 and 10 by 10 to get rid of the decimal, you get:
1/100 = 0.01 //Same result
这篇关于改变进度条为双的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!