码迷,mamicode.com
首页 > 移动开发 > 详细

Basic4Android中ProgressBar组建的演示

时间:2014-06-27 18:22:43      阅读:694      评论:0      收藏:0      [点我收藏+]

标签:des   android   class   blog   code   http   

#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

bubuko.com,布布扣

Basic4Android中ProgressBar组建的演示,布布扣,bubuko.com

Basic4Android中ProgressBar组建的演示

标签:des   android   class   blog   code   http   

原文地址:http://www.cnblogs.com/moodsky/p/3809803.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!