首页 > 代码库 > Basic4Android中ProgressBar组建的演示

Basic4Android中ProgressBar组建的演示

#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 will be declared once when the application starts.	‘These variables can be accessed from all modules.	Dim timer1 As Timer 	End SubSub Globals	‘These global variables will be redeclared each time the activity is created.	‘These variables can only be accessed from 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必须在 Activity_Create 初始化。			timer1.Initialize("timer1",100)		‘ 激活Timer		timer1.Enabled=True	End If		Dim gd As GradientDrawable    gd.Initialize("TOP_BOTTOM", Array As Int(Colors.Blue, Colors.Red))    gd.CornerRadius = 3dip		Dim 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/Height	End SubSub SetProgressDrawable1(p As ProgressBar, drawable As Object, backgroundDrawable As Object) ‘ 设置进度绘制	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.RunMethod("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‘   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.RunMethod("getProgressDrawable") ‘Gets the layerDrawable‘   r.RunMethod4("setDrawableByLayerId", _‘      Array As Object(r.GetStaticField("android.R$id", "progress"), clipDrawable), _‘      Array As String("java.lang.int", "android.graphics.drawable.Drawable"))‘End SubSub Activity_ResumeEnd SubSub Activity_Pause (UserClosed As Boolean)End SubSub timer1_Tick()	ProgressBar1.Progress = ProgressBar1.Progress + 1	If ProgressBar1.Progress = 100 Then		timer1.Enabled = False				ToastMessageShow("ProgressBar.Progress = 100 " ,True) ‘ 显示快速消息	End If	End Sub