I. Description
<1> In the process of continuous work, in order to prevent users from feelingProgramThe progress bar of the activity is required, indicating that the process is in progress.
<2> during some operationsA visual indicator that shows you the progress of the operation,It also has a secondary progress bar to display the intermediate progress, such as the progress in the buffer area of streaming media playback.A progress bar cannot be determined.In uncertain mode, the progress bar displays a circular animation.This mode is often used in applications. The length of a task is unknown.
Ii. Important XML attributes
Android: progressbarstyle: Default progress bar style
Android: progressbarstylehorizontal: horizontal style
Iii. Important Methods
Getmax():Returns the maximum range of the progress bar.
Getprogress(): Return the progress
Getsecondaryprogress(): Returns the secondary progress.
Incrementprogressby(INT diff): Specifies the increase progress.
Isindeterminate(): Indicates whether the progress bar is in uncertain mode.
Setindeterminate(Boolean indeterminate): sets the uncertain mode.
Setvisibility(Int v): sets whether the progress bar is visible.
4. Important Events
Onsizechanged(Int w, int H, int oldw, int oldh): this event is triggered when the progress value changes.
1. Default progress bar (medium circle)
<? XML version = "1.0" encoding = "UTF-8"?> <Br/> <linearlayout xmlns: Android = "http://schemas.android.com/apk/res/android" <br/> Android: layout_width = "fill_parent" <br/> Android: layout_height = "fill_parent" <br/> Android: Orientation = "vertical"> <br/> <textview <br/> Android: id = "@ + ID/Information" <br/> Android: layout_width = "fill_parent" <br/> Android: layout_height = "wrap_content" <br/> Android: TEXT = "(-) default progress bar (medium circle)"/> <br/> <progressbar <br/> Android: id = "@ + ID/processbar" <br/> Android: layout_width = "wrap_content" <br/> Android: layout_height = "wrap_content"/> <br/> </linearlayout>
2 progressbarstylelarge (large circle)
<Progressbar <br/> Android: Id = "@ + ID/processbar" <br/> Android: layout_width = "wrap_content" <br/> Android: layout_height = "wrap_content" <br/> style = "? Android: ATTR/progressbarstylelarge "/>
Progressbarstylesmall (small circle)
<Progressbar <br/> Android: Id = "@ + ID/processbar" <br/> Android: layout_width = "wrap_content" <br/> Android: layout_height = "wrap_content" <br/> style = "? Android: ATTR/progressbarstylesmall "/>
Progressbarstylesmalltitle Title Bar progress bar
Main. xml:
<Progressbar <br/> Android: Id = "@ + ID/processbar" <br/> Android: layout_width = "wrap_content" <br/> Android: layout_height = "wrap_content" <br/> style = "? Android: ATTR/progressbarstylesmalltitle "/>
Java
Package android2.test; </P> <p> Import android. app. activity; <br/> Import android. OS. bundle; <br/> Import android. view. window; </P> <p> public class android2activity extends activity {<br/>/** called when the activity is first created. */<br/> @ override <br/> Public void oncreate (bundle savedinstancestate) {<br/> super. oncreate (savedinstancestate); <br/> requestwindowfeature (window. feature_indeterminate_progress); <br/> setcontentview (R. layout. main); <br/> setprogressbarindeterminatevisibility (true); <br/>}< br/>}
Requestwindowfeature (window. feature_progress );
// Set the feature style of the window progress bar
Setprogressbarindeterminatevisibility (true); // you can specify the progress bar visibility.:
5. ssbarstylehorizontal (rectangular progress bar)
<Progressbar <br/> Android: Id = "@ + ID/progressbar" <br/> Android: layout_width = "200dp" <br/> Android: layout_height = "wrap_content" <br/> style = "? Android: ATTR/progressbarstylehorizontal "<br/> Android: max =" 100 "<br/> Android: Progress =" 50 "<br/> Android: secondaryprogress = "70" <br/>
Android: max = "100" maximum progress: 100
Android: Progress = "50" Current initialization progress value: 50
Android: secondaryprogress = "70" Current initialization 2nd Progress value 70
Sat.