Android ApiDemos example resolution (182): Views-& gt; Progress Bar-& gt

Source: Internet
Author: User

Process entry ProgressBar can be used to display the current progress of an operation (such as downloading an object). The application can change the length of a process entry based on the Operation progress. The process bar in Android also supports a secondary progress bar to display the progress of any intermediate operation. For example, if you extract a file package, the main progress bar can display the decompression progress of the entire file package, the secondary progress bar displays the progress of the files being decompressed.

You can set the ProgressBar to "indeterminate" mode if you do not know the time required for the operation. At this time, the progress bar can display a rolling wheel or a horizontal progress bar.

Define ProgressBar in Layout, such:


[Html]
<ProgressBar android: id = "@ + id/progress_horizontal"
Style = "? Android: attr/progressBarStyleHorizontal"
Android: layout_width = "200dip"
Android: layout_height = "wrap_content"
Android: max = "100 ″
Android: progress = "50 ″
Android: secondaryProgress = "75"/>

<ProgressBar android: id = "@ + id/progress_horizontal"
Style = "? Android: attr/progressBarStyleHorizontal"
Android: layout_width = "200dip"
Android: layout_height = "wrap_content"
Android: max = "100 ″
Android: progress = "50 ″
Android: secondaryProgress = "75"/>


ProgressBar is displayed as a Spinning Wheel by default. If you want to use a horizontal progress bar, set its mode to progressBarStyleHorizontal. (Or style = "@ android: style/Widget. ProgressBar. Horizontal) if you need to specify the current progress value of the progress bar, you must use the Horizontal progress bar style.

Another common style is Widget. ProgressBar. Small, which is represented as a Small rotating wheel. It can be used to represent a delayed operation (such as downloading) in the application)

ProgressBar supports the following styles:

Widget. ProgressBar. Horizontal
Widget. ProgressBar. Small
Widget. ProgressBar. Large
Widget. ProgressBar. Inverse
Widget. ProgressBar. Small. Inverse
Widget. ProgressBar. Large. Inverse

If attr is used, the following attr can be used:

ProgressBarStyle
ProgressBarStyleHorizontal
ProgressBarStyleInverse
ProgressBarStyleLarge
ProgressBarStyleLargeInverse
ProgressBarStyleSmall
ProgressBarStyleSmallInverse
ProgressBarStyleSmallTitle

Inverse indicates that the progress bar is displayed in Reversed colors.

This example introduces the basic usage of ProgressBar. You can click the button to modify the progress value of the progress bar (two progress bars are used at the same time: the main progress bar and the secondary progress bar ).

Note that Activity also provides several methods related to the progress bar (displayed in the title bar) to control the progress bar display.

SetProgress (int progress)
SetProgressBarIndeterminate (boolean indeterminate)
SetProgressBarIndeterminateVisibility (boolean visible)
SetProgressBarVisibility (boolean visible)
For ProgressBar, the current value of the progress bar is modified through incrementProgressBy and incrementSecondaryProgressBy.

[Java]
Final ProgressBar progressHorizontal
= (ProgressBar) findViewById (R. id. progress_horizontal );
SetProgress (progressHorizontal. getProgress () * 100 );
SetSecondaryProgress (progressHorizontal. getSecondaryProgress ()
* 100 );
 
...
ProgressHorizontal. incrementProgressBy (-1 );
...
ProgressHorizontal. incrementSecondaryProgressBy (-1 );

Final ProgressBar progressHorizontal www.2cto.com
= (ProgressBar) findViewById (R. id. progress_horizontal );
SetProgress (progressHorizontal. getProgress () * 100 );
SetSecondaryProgress (progressHorizontal. getSecondaryProgress ()
* 100 );

...
ProgressHorizontal. incrementProgressBy (-1 );
...
ProgressHorizontal. incrementSecondaryProgressBy (-1 );

 


 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.