'Class module
Sub Class_Globals
Private ac As Activity
Private mCallback As Object
Private pane As Panel
Private al As Double
Private mEventName As String
End Sub
Public Sub Initialize(M As Object, A As Activity, B() As Bitmap, L() As String, Alfa As Int, EventName As String)
mCallback = M
ac = A
mEventName = EventName
Dim xw,xh,xl,xt,space,panexw As Int
xw = 64dip
xh = xw
xl = space
xt = 0
pane.Initialize("pane")
pane.Color = Colors.ARGB(Alfa,255,255,255)
xPanelAnimation(pane)
ac.AddView(pane,5%x,(98%y)-(xh),90%x,xh)
xw = (pane.Width-((20%X/B.Length)*B.Length)) / B.Length ' ridimensiona altezza e larghezza button
xh = xw
xl = ((pane.Width- xw*B.Length )/2)-(3dip*B.Length) ' trova il centro di tutto
xt = ((pane.Height-xh)/2)
For i = 0 To B.Length-1
Dim xb As Button
xb.Initialize("bt")
xb.Tag = i
xb.Tag = L(i)
xb.SetBackgroundImage(CreateScaledBitmap(B(i),xw,xh))
pane.AddView(xb,xl,xt,xw,xh)
xl = xl + 2.5%x + xw
Next
End Sub
Private Sub xPanelAnimation(v As View)
Dim a1 As Animation
a1.InitializeAlpha("",0,1)
a1.Duration=1000
a1.Start(v)
End Sub
Private Sub xPanelCloseAnimation(v As View)
Dim a1 As Animation
a1.InitializeAlpha("a1",1,0)
a1.Duration=1500
a1.Start(v)
End Sub
Sub a1_AnimationEnd
For i = 0 To ac.NumberOfViews-1
If ac.GetView(i).tag = "pn" Then
ac.RemoveViewAt(i)
Return
End If
Next
End Sub
Private Sub CreateScaledBitmap(Original As Bitmap, Width As Int, Height As Int) As Bitmap
Dim r As Reflector
Dim b As Bitmap
Dim filter As Boolean: filter=True
b = r.RunStaticMethod("android.graphics.Bitmap", "createScaledBitmap", _
Array As Object(Original, Width, Height, filter), _
Array As String("android.graphics.Bitmap", "java.lang.int", "java.lang.int", "java.lang.boolean"))
Return b
End Sub
Private Sub bt_Click
Dim bt As Button = Sender
Dim Value As Object
Value = bt.tag
If SubExists(mCallback, mEventName & "_Click") Then
CallSubDelayed2(mCallback, mEventName & "_Click",Value)
End If
End Sub