问题描述
我有一个进度条,用于显示已完成任务的百分比。这是我的屏幕截图:
I have an progress bar for displaying percentage of task being completed. Here is my screenshot:
如您所见,左边的文本是确定的。但是我希望右边的文本显示正在加载的项目数,而不是像左边的那样显示百分比。例如,我有200个项目,而我想要的rigth文本应显示为:13 / 200、27 / 200 .... etc。如何设置此属性?
As you can see, the left text is OK. But I want the right text display the number of item being loaded, not percentage like the left one. For example, I have 200 item and I want the rigth text should display like: 13/200, 27/200....etc. How can I set this property?
推荐答案
正确的文本被命名为 progress,并且可以设置其最大值使用 progressBar.setMax(number)
方法。
The "right text" is named "progress", and its maximum value can be set with the progressBar.setMax(number)
method.
要显示从零到最大的进度,您可以执行以下操作:
To show your progress from zero to max you could then do something like:
progressBar.setProgress(0);
for(int i = 0; i < items.length; i++) {
// Do stuff
progressBar.incrementProgressBy(1);
}
这篇关于Android进度栏任务计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!