How to set maximum value of progressbar in Android [closed]

好久不见. 提交于 2019-12-23 19:15:02

问题


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.

like:

progressbar.maximum = 100;

while(progressbar ! = 100)
{
    progressbar.value + 1;
}

回答1:


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.

Must be an integer value, such as "100".

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"
/>

or
probressbar.setMax(Value);




回答2:


you can set progressbar by two way

probressbar.setMax(maxValue);

or from in xml

<ProgressBar
     android:max="maxvalue"/>



回答3:


You should be able to do the following:

progressbar.setMax(maxValue);

Take a look at the API for ProgressBars here.



来源:https://stackoverflow.com/questions/12616269/how-to-set-maximum-value-of-progressbar-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!