如何在Android中设置进度条的最大值 [英] How to set maximum value of progressbar in Android
问题描述
你好,我是android&的初学者我正在创建简单的progressbar程序.在我的程序中,我想设置进度条最大值&.我想使用循环来增加进度栏的进度,直到没有完成为止.我想按一下按钮来执行此任务.
hello i am beginner in android & i am creating simple progressbar program. In my program i want to set progressbar maximum value & i want to increase progressbar progress using a loop till it's not get complete i want to perform this task on butten click.
喜欢:
progressbar.maximum = 100;
while(progressbar ! = 100)
{
progressbar.value + 1;
}
推荐答案
默认情况下,进度条在达到100时已满.
如有必要,您可以使用android:max属性调整最大值(完整条的值)
By default, the progress bar is full when it reaches 100.
If necessary, you can adjust the maximum value (the value for a full bar) using the android:max attribute
android:max
定义进度可以采用的最大值.
Defines the maximum value the progress can take.
必须为整数值,例如"100".
Must be an integer value, such as "100".
这也可能是对包含值的资源(形式为"@ [package:] type:name")或主题属性(形式为?[package:] [type:] name")的引用这种类型的.
This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.
<ProgressBar
android:id="@+id/progressbar"
style="@android:style/Widget.ProgressBar.Horizontal"
android:max="42" <--- it's the answer)
android:progress="0"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/bottom_header_relativelayout"
/>
或
probressbar.setMax(Value);
这篇关于如何在Android中设置进度条的最大值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!