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 Region Sub 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 Sub Sub 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 ProgressBar End Sub Sub 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 Sub Sub 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 Sub Sub Activity_Resume End Sub Sub Activity_Pause (UserClosed As Boolean) End Sub Sub timer1_Tick() ProgressBar1.Progress = ProgressBar1.Progress + 1 If ProgressBar1.Progress = 100 Then timer1.Enabled = False ToastMessageShow("ProgressBar.Progress = 100 " ,True) ‘ 显示快速消息 End If End Sub
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。