This shows the progress bar of the Android ProgressBar, because the Android bar progress bar is initially static and not like a circular progress bar is dynamic;
And Seekbar is the drag bar of Android, use the scene such as music or video playback in the time ~ ~ ~
XML layout file (Note that the style type to be selected when using the bar progress bar is
"? Android:attr/progressbarstylehorizontal"
):
<Relativelayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Xmlns:tools= "Http://schemas.android.com/tools"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"Android:paddingbottom= "@dimen/activity_vertical_margin"Android:paddingleft= "@dimen/activity_horizontal_margin"Android:paddingright= "@dimen/activity_horizontal_margin"Android:paddingtop= "@dimen/activity_vertical_margin"Tools:context=". Mainactivity "Android:background= "#BBBB0000"> <ProgressBarAndroid:id= "@+id/pb"Android:layout_width= "Fill_parent"Android:layout_height= "Wrap_content"style= "? Android:attr/progressbarstylehorizontal"Android:max= "+"android:progress= " the"android:secondaryprogress= "The "/> <SeekBarAndroid:id= "@+id/seekbar"Android:layout_width= "Fill_parent"Android:layout_height= "Wrap_content"Android:layout_below= "@id/pb"Android:text= "Drag"/></Relativelayout>
Mainactivity.java file:
Importandroid.app.Activity;ImportAndroid.os.Bundle;ImportAndroid.util.Log;ImportAndroid.widget.ProgressBar;ImportAndroid.widget.SeekBar;ImportAndroid.widget.SeekBar.OnSeekBarChangeListener; Public classMainactivityextendsActivityImplementsRunnable, Onseekbarchangelistener {PrivateProgressBar PB; PrivateThread th; BooleanStateChange; SeekBar SeekBar; PrivateString tag = "SEEKBAR"; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); Setcontentview (R.layout.activity_main); PB=(ProgressBar) Findviewbyid (R.ID.PB); Seekbar=(SeekBar) Findviewbyid (R.id.seekbar); Seekbar.setonseekbarchangelistener ( This); Th=NewThread ( This); Th.start (); } @Override Public voidOnprogresschanged (SeekBar arg0,intArg1,Booleanarg2) { //TODO auto-generated Method StubLOG.V (Tag, "Drag Change"); } @Override Public voidOnstarttrackingtouch (SeekBar arg0) {//TODO auto-generated Method StubLOG.V (Tag, "Change in"); } @Override Public voidOnstoptrackingtouch (SeekBar arg0) {//TODO auto-generated Method StubLOG.V (tag, "Stop changing"); } @Override Public voidrun () {//TODO auto-generated Method Stub while(true){ intCurrent =pb.getprogress (); intCurrentmax =Pb.getmax (); intSeccurrent =pb.getsecondaryprogress (); if(StateChange = =false) { if(Current <Currentmax) {pb.setprogress ( current+1); Pb.setsecondaryprogress ( current+1); }Else if(Current = =Currentmax) {StateChange=true; } } Else{ if(Current > 0) {pb.setprogress ( current-1); Pb.setsecondaryprogress ( current-1); }Else if(current = = 0) {StateChange=false; } } Try{Thread.Sleep (100); } Catch(Exception e) {//Todo:handle ExceptionE.printstacktrace (); } } } }
Run effect (the business code for the progress bar is the constant change in the simulation progress)
The picture can't actually upload today, wait for a while to fill up again.