Hi guys,
I don't understand why it doesn't work....
Thanks a lot !
Good evening.
Fred
I don't understand why it doesn't work....
B4X:
#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: landscape
#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.
End Sub
Sub Globals
Dim pb1,pb2,pb3,pb4 As ProgressBar
Dim pb() As ProgressBar
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("test")
pb = Array As ProgressBar(pb1, pb2, pb3, pb4)
For i=0 To 3
pb(0).Initialize("pb")
Next
Dim gd As GradientDrawable
gd.Initialize("TOP_BOTTOM", Array As Int(Colors.green, Colors.green))
gd.CornerRadius = 3dip
Dim cd As ColorDrawable
cd.Initialize(Colors.black, 3dip)
For i = 0 To 3
SetProgressDrawable(pb(i), gd, cd)
pb(i).Progress = 50
Next
Activity.AddView(pb(0), 10dip, 10dip, 90dip, 10dip)
Activity.AddView(pb(1), 30dip, 10dip, 90dip, 10dip)
Activity.AddView(pb(2), 50dip, 10dip, 90dip, 10dip)
Activity.AddView(pb(3), 80dip, 10dip, 90dip, 10dip)
End Sub
Sub SetProgressDrawable(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
Thanks a lot !
Good evening.
Fred