Register alpha.0 B4A prototype
This commit is contained in:
137
droplist.bas
Normal file
137
droplist.bas
Normal file
@@ -0,0 +1,137 @@
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=2.02
|
||||
@EndOfDesignText@
|
||||
'Class module
|
||||
Sub Class_Globals
|
||||
Dim pnlMn As Panel
|
||||
Dim lblMn As Label
|
||||
Dim btnMn As ImageView
|
||||
Dim dpnl As Panel
|
||||
Dim dlst As ListView
|
||||
Dim dlItems As List
|
||||
Dim isOpen As Boolean
|
||||
Dim selPos As Int
|
||||
Dim selVal As String
|
||||
Dim selEvent As String
|
||||
End Sub
|
||||
|
||||
'Initializes the object. You can add parameters to this method if needed.
|
||||
Public Sub Initialize(pnl As Panel, txt As String, evn As String)
|
||||
Dim i, j, k As Int
|
||||
Dim spc As String
|
||||
Dim bp As Panel
|
||||
Dim v As Panel
|
||||
|
||||
i = pnl.Height
|
||||
j = pnl.Width
|
||||
pnlMn = pnl
|
||||
dlItems.Initialize
|
||||
|
||||
pnl.Color = Colors.Gray
|
||||
|
||||
spc = " "
|
||||
|
||||
Dim gd1 As GradientDrawable
|
||||
Dim cl1(2) As Int
|
||||
cl1(0) = Colors.ARGB(255, 220, 220, 220)
|
||||
cl1(1) = Colors.ARGB(255, 160, 160, 160)
|
||||
gd1.Initialize("TOP_BOTTOM", cl1)
|
||||
|
||||
lblMn.Initialize("") ' control main label
|
||||
pnl.AddView(lblMn, 0, 0, j-i-1, i)
|
||||
lblMn.Background = gd1
|
||||
lblMn.Gravity = Gravity.LEFT + Gravity.CENTER_VERTICAL
|
||||
lblMn.TextColor = Colors.Black
|
||||
lblMn.TextSize = 18
|
||||
lblMn.Text = spc & txt
|
||||
|
||||
Dim gd2 As GradientDrawable
|
||||
Dim cl2(2) As Int
|
||||
cl2(0) = Colors.ARGB(255, 220, 220, 220)
|
||||
cl2(1) = Colors.ARGB(255, 160, 160, 160)
|
||||
gd2.Initialize("TOP_BOTTOM", cl2)
|
||||
|
||||
bp.Initialize("") ' button panel for drop button image
|
||||
pnl.AddView(bp, j-i, 0, i, i)
|
||||
bp.Background = gd2
|
||||
|
||||
btnMn.Initialize("btnMn")
|
||||
bp.AddView(btnMn, 0, 0, i, i)
|
||||
|
||||
Dim sld1 As StateListDrawable
|
||||
Dim enb, psd As BitmapDrawable
|
||||
|
||||
enb.Initialize(LoadBitmap(File.DirAssets, "drpimg.png"))
|
||||
psd.Initialize(LoadBitmap(File.DirAssets, "drpimgp.png"))
|
||||
|
||||
sld1.Initialize
|
||||
sld1.AddState(sld1.State_Pressed, psd)
|
||||
sld1.AddState(sld1.State_Enabled, enb)
|
||||
|
||||
btnMn.Gravity = Gravity.FILL
|
||||
btnMn.Background = sld1
|
||||
|
||||
Dim cd3 As ColorDrawable
|
||||
cd3.Initialize(Colors.Gray, 5dip)
|
||||
|
||||
dpnl.Initialize("") ' the drop panel
|
||||
dpnl.Background = cd3
|
||||
v = GetParent(pnl)
|
||||
v.AddView(dpnl, pnl.Left+j*0.03, pnl.Top+i, j, 5*i)
|
||||
|
||||
Dim cd4 As ColorDrawable
|
||||
cd4.Initialize(Colors.LightGray, 5dip)
|
||||
|
||||
dlst.Initialize("dlst") ' the drop panel listview
|
||||
dpnl.AddView(dlst, 0, 0, dpnl.Width, dpnl.Height)
|
||||
dlst.SingleLineLayout.Background = cd4
|
||||
dlst.SingleLineLayout.ItemHeight = pnl.Height
|
||||
dlst.SingleLineLayout.Label.TextColor = Colors.Black
|
||||
dlst.SingleLineLayout.Label.TextSize = 18
|
||||
dlst.SingleLineLayout.Label.Gravity = Gravity.CENTER_HORIZONTAL + Gravity.CENTER_VERTICAL
|
||||
|
||||
dpnl.Enabled = False
|
||||
dpnl.Visible = False
|
||||
|
||||
isOpen = False
|
||||
selPos = -1
|
||||
selVal = ""
|
||||
selEvent = evn
|
||||
End Sub
|
||||
|
||||
Sub btnMn_Click
|
||||
If (isOpen = True) Then
|
||||
isOpen = False
|
||||
dpnl.Enabled = False
|
||||
dpnl.Visible = False
|
||||
Else
|
||||
isOpen = True
|
||||
|
||||
dlst.Clear
|
||||
For i=0 To dlItems.Size-1
|
||||
dlst.AddSingleLine(dlItems.Get(i))
|
||||
Next
|
||||
|
||||
dpnl.Enabled = True
|
||||
dpnl.Visible = True
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub dlst_ItemClick (pos As Int, val As Object)
|
||||
selPos = pos
|
||||
selVal = val
|
||||
lblMn.Text = " " & val
|
||||
|
||||
If (isOpen = False) Then Return
|
||||
|
||||
CallSubDelayed(Main, selEvent)
|
||||
btnMn_Click
|
||||
End Sub
|
||||
|
||||
Sub GetParent(v As View) As View
|
||||
Dim r As Reflector
|
||||
r.Target = v
|
||||
Return r.RunMethod("getParent")
|
||||
End Sub
|
||||
Reference in New Issue
Block a user