Demonstration of ProgressBar formation in basic4android

Source: Internet
Author: User

#Region Project Attributes #ApplicationLabel: progressbartest#versioncode:20140626#versionname: ' Supportedorientations possible values:unspecified, landscape or Portrait. #SupportedOrientations: unspecified# Caninstalltoexternalstorage:false#end region#region Activity Attributes #FullScreen: false#includetitle:true#end Regionsub process_globals ' These global variables would be declared once when the application starts. ' These variables can is accessed from all modules. Dim timer1 as Timer End SubSub Globals ' These global variables would be redeclared each time the activity is created. ' These variables can only is accessed from the This module. Private ProgressBar1 as Progressbarend SubSub Activity_create (firsttime as Boolean) ' Do not forget to load the layout file Created with the visual designer. For example: ' Activity.loadlayout ("LAYOUT1") progressbar1.initialize ("ProgressBar1") If Firsttime Then Activity.loadlayout ("1") ' timer must be initialized in Activity_create. Timer1. Initialize ("Timer1", 100) ' activating timertimeR1. Enabled=trueend Ifdim GD as Gradientdrawable GD. Initialize ("Top_bottom", Array as Int (Colors.blue, colors.red)) gd. Cornerradius = 3dipDim CD as colordrawable CD. Initialize (colors.transparent, 3dip) ' Setprogressdrawable (ProgressBar1, GD) SetProgressDrawable1 (ProgressBar1, GD, CD) progressbar1.setlayout (20%x,30,60%x,30) ' Left/top/width/heightend SubSub SetProgressDrawable1 (p as ProgressBar,  Drawable As Object, backgrounddrawable as Object) ' Set progress to draw Dim R As Reflector Dim clipdrawable As Object clipdrawable =  R.createobject2 ("Android.graphics.drawable.ClipDrawable", _ Array as Object (drawable, Gravity.left, 1), _ array As String ("Android.graphics.drawable.Drawable", "Java.lang.int", "Java.lang.int")) R.target = P R.target = R.runmetho D ("getprogressdrawable") ' Gets the layerdrawable r.runmethod4 ("Setdrawablebylayerid", _ Array as Object (16908288 , backgrounddrawable), _ Array as String ("Java.lang.int", "android.graphics.drawable.Drawable")) r.ruNMETHOD4 ("Setdrawablebylayerid", _ Array as Object (R.getstaticfield ("Android. R$id "," Progress "), clipdrawable), _ Array as String (" Java.lang.int "," android.graphics.drawable.Drawable ")) End Sub ' Sub setprogressdrawable (p as ProgressBar, drawable as Object) ' Dim R As Reflector ' Dim clipdrawable As Object ' clip drawable = R.createobject2 ("android.graphics.drawable.ClipDrawable", _ ' Array as Object (drawable, Gravity.left, 1), _ ' Array as String ("Android.graphics.drawable.Drawable", "Java.lang.int", "Java.lang.int")) ' R.target = P ' R.targe t = R.runmethod ("getprogressdrawable") ' Gets the Layerdrawable ' r.runmethod4 ("Setdrawablebylayerid", _ ' Array as Ob Ject (R.getstaticfield ("Android. R$id "," Progress "), clipdrawable), _ ' Array as String (" Java.lang.int "," android.graphics.drawable.Drawable ")) ' End Sub Sub activity_resumeend SubSub Activity_pause (userclosed as Boolean) End SubSub Timer1_Tick () progressbar1.progress = Progressbar1.progress + 1If ProgressBar1.Progress = thentimer1.enabled = Falsetoastmessageshow ("progressbar.progress = +", True) ' Show quick message End IfEnd Sub 

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.