Android进度栏任务计数

编程入门 行业动态 更新时间:2024-10-28 18:23:36
本文介绍了Android进度栏任务计数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个进度条,用于显示已完成任务的百分比。这是我的屏幕截图:

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进度栏任务计数

本文发布于:2023-11-09 03:01:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1571214.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:进度   Android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!