ProgressBar进度条Word文档格式.docx
《ProgressBar进度条Word文档格式.docx》由会员分享,可在线阅读,更多相关《ProgressBar进度条Word文档格式.docx(30页珍藏版)》请在冰豆网上搜索。
privateintmProgressStatus=0;
privateHandlermHandler=newHandler();
protectedvoidonCreate(Bundleicicle){
super.onCreate(icicle);
setContentView(R.layout.progressbar_activity);
mProgress=(ProgressBar)findViewById(R.id.progress_bar);
//Startlengthyoperationinabackgroundthread
newThread(newRunnable(){
publicvoidrun(){
while(mProgressStatus<
100){
mProgressStatus=doWork();
//Updatetheprogressbar
mHandler.post(newRunnable(){
mProgress.setProgress(mProgressStatus);
}
});
}).start();
Toaddaprogressbartoalayoutfile,youcanusethe<
ProgressBar>
element.Bydefault,theprogressbarisaspinningwheel(anindeterminateindicator).Tochangetoahorizontalprogressbar,applytheWidget.ProgressBar.Horizontalstyle,likeso:
<
ProgressBar
style="
@android:
style/Widget.ProgressBar.Horizontal"
.../>
Ifyouwillusetheprogressbartoshowrealprogress,youmustusethehorizontalbar.YoucanthenincrementtheprogresswithincrementProgressBy()orsetProgress().Bydefault,theprogressbarisfullwhenitreaches100.Ifnecessary,youcanadjustthemaximumvalue(thevalueforafullbar)usingtheandroid:
maxattribute.Otherattributesavailablearelistedbelow.
AnothercommonstyletoapplytotheprogressbarisWidget.ProgressBar.Small,whichshowsasmallerversionofthespinningwheel—usefulwhenwaitingforcontenttoload.Forexample,youcaninsertthiskindofprogressbarintoyourdefaultlayoutforaviewthatwillbepopulatedbysomecontentfetchedfromtheInternet—thespinningwheelappearsimmediatelyandwhenyourapplicationreceivesthecontent,itreplacestheprogressbarwiththeloadedcontent.Forexample:
LinearLayout
android:
orientation="
horizontal"
...>
layout_width="
wrap_content"
layout_height="
style/Widget.ProgressBar.Small"
layout_marginRight="
5dp"
/>
TextView
text="
@string/loading"
/LinearLayout>
Otherprogressbarstylesprovidedbythesysteminclude:
Widget.ProgressBar.Horizontal
Widget.ProgressBar.Small
Widget.ProgressBar.Large
Widget.ProgressBar.Inverse
Widget.ProgressBar.Small.Inverse
Widget.ProgressBar.Large.Inverse
The"
inverse"
stylesprovideaninversecolorschemeforthespinner,whichmaybenecessaryifyourapplicationusesalightcoloredtheme(awhitebackground).
XMLattributes
SeeProgressBarAttributes,ViewAttributes
Summary
XMLAttributes
AttributeNameRelatedMethodDescription
android:
animationResolutionTimeoutbetweenframesofanimationinmilliseconds
Mustbeanintegervalue,suchas"
100"
.
indeterminateAllowstoenabletheindeterminatemode.
indeterminateBehaviorDefineshowtheindeterminatemodeshouldbehavewhentheprogressreachesmax.
indeterminateDrawableDrawableusedfortheindeterminatemode.
indeterminateDurationDurationoftheindeterminateanimation.
indeterminateOnlyRestrictstoONLYindeterminatemode(state-keepingprogressmodewillnotwork).
indeterminateTintsetIndeterminateTintList(ColorStateList)Tinttoapplytotheindeterminateprogressindicator.
indeterminateTintModesetIndeterminateTintMode(PorterDuff.Mode)Blendingmodeusedtoapplytheindeterminateprogressindicatortint.
interpolator
maxDefinesthemaximumvaluetheprogresscantake.
maxHeightAnoptionalargumenttosupplyamaximumheightforthisview.
maxWidthAnoptionalargumenttosupplyamaximumwidthforthisview.
minHeight
minWidth
mirrorForRtlDefinesiftheassociateddrawablesneedtobemirroredwheninRTLmode.
progressDefinesthedefaultprogressvalue,between0andmax.
progressBackgroundTintsetProgressBackgroundTintList(ColorStateList)Tinttoapplytotheprogressindicatorbackground.
progressBackgroundTintModesetProgressBackgroundTintMode(PorterDuff.Mode)Blendingmodeusedtoapplytheprogressindicatorbackgroundtint.
progressDrawableDrawableusedfortheprogressmode.
progressTintsetProgressTintList(ColorStateList)Tinttoapplytotheprogressindicator.
progressTintModesetProgressTintMode(PorterDuff.Mode)Blendingmodeusedtoapplytheprogressindicatortint.
secondaryProgressDefinesthesecondaryprogressvalue,between0andmax.
secondaryProgressTintsetSecondaryProgressTintList(ColorStateList)Tinttoapplytothesecondaryprogressindicator.
secondaryProgressTintModesetSecondaryProgressTintMode(PorterDuff.Mode)Blendingmodeusedtoapplythesecondaryprogressindicatortint.
[Expand]
InheritedXMLAttributes
Fromclassandroid.view.View
InheritedConstants
InheritedFields
PublicConstructors
ProgressBar(Contextcontext)
Createanewprogressbarwithrange0...100andinitialprogressof0.
ProgressBar(Contextcontext,AttributeSetattrs)
ProgressBar(Contextcontext,AttributeSetattrs,intdefStyleAttr)
ProgressBar(Contextcontext,AttributeSetattrs,intdefStyleAttr,intdefStyleRes)
PublicMethods
voiddrawableHotspotChanged(floatx,floaty)
Thisfunctioniscalledwhenevertheviewhotspotchangesandneedstobepropagatedtodrawablesorchildviewsmanagedbytheview.
CharSequencegetAccessibilityClassName()
Returntheclassnameofthisobjecttobeusedforaccessibilitypurposes.
DrawablegetIndeterminateDrawable()
Getthedrawableusedtodrawtheprogressbarinindeterminatemode.
ColorStateListgetIndeterminateTintList()
PorterDuff.ModegetIndeterminateTintMode()
Returnstheblendingmodeusedtoapplythetinttotheindeterminatedrawable,ifspecified.
InterpolatorgetInterpolator()
Getstheaccelerationcurvetypefortheindeterminateanimation.
synchronizedintgetMax()
Returntheupperlimitofthisprogressbar'
srange.
synchronizedintgetProgress()
Gettheprogressbar'
scurrentlevelofprogress.
ColorStateListgetProgressBackgroundTintList()
Returnsthetintappliedtotheprogressbackground,ifspecified.
PorterDuff.ModegetProgressBackgroundTintMode()
DrawablegetProgressDrawable()
Getthedrawableusedtodrawtheprogressbarinprogressmode.
ColorStateListgetProgressTintList()
Returnsthetintappliedtotheprogressdrawable,ifspecified.
PorterDuff.ModegetProgressTintMode()
Returnstheblendingmodeusedtoapplythetinttotheprogressdrawable,ifspecified.
synchronizedintgetSecondaryProgress()
scurrentlevelofsecondaryprogress.
ColorStateListgetSecondaryProgressTintList()
Returnsthetintappliedtothesecondaryprogressdrawable,ifspecified.
PorterDuff.ModegetSecondaryProgressTintMode()
Returnstheblendingmodeusedtoapplythetinttothesecondaryprogressdrawable,ifspecified.
synchronizedfinalvoidincrementProgressBy(intdiff)
Increasetheprogressbar'
sprogressbythespecifiedamount.
synchronizedfinalvoidincrementSecondaryProgressBy(intdiff)
ssecondaryprogressbythespecifiedamount.
voidinvalidateDrawable(Drawabledr)
InvalidatesthespecifiedDrawable.
synchronizedbooleanisIndeterminate()
Indicatewhetherthisprogressbarisinindeterminatemode.
voidjumpDrawablesToCurrentState()
CallDrawable.jumpToCurrentState()onallDrawableobjectsassociatedwiththisview.
voidonRestoreInstanceState(Parcelablestate)
Hookallowingaviewtore-applyarepresentationofitsinternalstatethathadpreviouslybeengeneratedbyonSaveInstanceState().
ParcelableonSaveInstanceState()
Hookallowingaviewtogeneratearepresentationofitsinternalstatethatcanlaterbeusedtocreateanewinstancewiththatsamestate.
voidpostInvalidate()
Causeaninvalidatetohappenonasubsequentcyclethroughtheeventloop.
synchronizedvoidsetIndeterminate(booleanindeterminate)
Changetheindeterminatemodeforthisprogressbar.
voidsetIndeterminateDrawable(Drawabled)
Definethedrawableusedtodrawtheprogressbarinindeterminatemode.
voidsetIndeterminateDrawableTiled(Drawabled)
Definethetileabledrawableusedtodrawtheprogressbarinindeterminatemode.
voidsetIndeterminateTintList(ColorStateListtint)
Appliesatinttotheindeterminatedrawable.
voidsetIndeterminateTintMode(PorterDuff.ModetintMode)
Specifiestheblendingmodeu