Sub Activity_Create(FirstTime As Boolean)
Activity.Color = Colors.White
Dim cd As ColorDrawable
cd.Initialize2(Colors.Blue,15dip,0dip,Colors.Blue)
Dim AltoLabel, TopLabel, LeftLabel, Espacio, TotalLabels As Int
Dim AnchoLabel As Float
AltoLabel = 35dip
TopLabel = 5dip
LeftLabel = 5dip
Espacio = 15dip
TotalLabels = 10
Dim bmp As Bitmap
Dim cvs As Canvas
bmp.InitializeMutable(1,1) 'ignore
cvs.Initialize2(bmp)
For n = 1 To TotalLabels
Dim Label1 As Label
Label1.Initialize("Label1")
Label1.TextSize = 16
Label1.Typeface = Typeface.DEFAULT
Label1.Background = cd
Label1.Gravity = Gravity.CENTER
Label1.Tag = n
Label1.TextColor = Colors.White
Label1.Padding = Array As Int (5dip, 0, 5dip, 0)
SetElevation(Label1, 30.0)
If n Mod 2 = 0 Then
Label1.Text ="Texto mas largo"
Else
Label1.Text ="Texto"
End If
Activity.AddView(Label1,LeftLabel,TopLabel,-2,AltoLabel)
AnchoLabel = cvs.MeasureStringWidth(Label1.Text, Label1.Typeface,Label1.TextSize)
LeftLabel = LeftLabel + AnchoLabel + Espacio
If LeftLabel > 100%x Then
TopLabel = TopLabel + AltoLabel + Espacio
LeftLabel = 5dip
Label1.Top = TopLabel
Label1.Left = LeftLabel
LeftLabel = LeftLabel + AnchoLabel + Espacio
End If
Next
End Sub
Sub SetElevation(v As View, e As Float)
Dim jo As JavaObject
Dim p As Phone
If p.SdkVersion >= 21 Then
jo = v
jo.RunMethod("setElevation", Array As Object(e))
End If
End Sub
Sub Label1_Click
Dim lbl As Label
lbl = Sender
ToastMessageShow("Label" & lbl.tag, False)
End Sub