XML File Code section
<progressbar android:id= "@+id/firstprobar" android: Layout_width= "Match_parent" android:layout_height= "Wrap_content" android:max= " android:progress=" " style="? Android: Attr/progressbarstylehorizontal " /><button android: Id= "@+id/bt1" android:layout_width= "Wrap_content" android:layout _height= "Wrap_content" android:layout_below= "@id/firstprobar" Android:text= "Forward" /><button android:id= "@+id/bt2" android:layout_width= "wrap_content" android:layout_height= "wrap _content " android:layout_below=" @id/bt1 " android:text=" back />
Mainactivity in code
private progressbar probar;private button bt1;private button bt2; @Override protected void oncreate (bundle savedinstancestate) { super.oncreate (savedinstancestate); setcontentview (R.layout.activity_main); probar= (ProgressBar) Findviewbyid (R.id.firstprobar); probar.setmax (+); /*probar.setprogress (; ) boolean flag=probar.isindeterminate (); toast.maketext (Getapplicationcontext (), flag+ "", toast.length_long). Show (); */ bt1= (Button) Findviewbyid (R.ID.BT1); bt2= (ButtoN) Findviewbyid (R.ID.BT2); firstlis f=new firstlis (); secondlis s=new secondlis (); bt1.setonclicklistener (f); Bt2.setonclicklistener (s); } class firstlis implements onclicklistener{@Overridepublic void onclick (view v) {probar.incrementprogressby (10) ;} } class secondlis implements onclicklistener{@Overridepublic void onclick (view v) { Probar.incrementprogressby (-10);} }
This article is from the "Java White Battlefield" blog, be sure to keep this source http://8023java.blog.51cto.com/10117207/1660207
Android progress bar ProgressBar