Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
B4XPages.SetTitle(Me, "Menu Icons")
Root.LoadLayout("MainPage")
CartBitmap = xui.LoadBitmap(File.DirAssets, "cart.png")
Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(0, 0, 0, 32dip, 32dip)
IconCanvas.Initialize(p)
UpdateMenuItems
'Add the following
addCustomItem("Item")
addCustomItem("Another Item")
addCustomItem("A Third Item")
addCustomItem("A Final Item")
CustomListView1.PressedColor = xui.Color_Transparent
End Sub
Private Sub B4XPage_MenuClick (Tag As String)
If Tag = "cart" Then Panel1.Visible = True
End Sub
Private Sub addCustomItem(text As String)
Dim w As Float = CustomListView1.GetBase.Width
Dim pnl As B4XView = xui.CreatePanel("")
pnl.SetColorAndBorder(xui.Color_White, 0, 0, 0)
pnl.SetLayoutAnimated(0, 0, 0, w, 40dip)
Dim lab As Label
lab.Initialize("")
Dim labx As B4XView = lab
labx.SetTextAlignment("CENTER", "RIGHT")
labx.Text = text
pnl.AddView(labx, 5dip, 0, .65 * w, 40dip)
Dim chk As CheckBox
chk.Initialize("")
chk.Tag = text
Dim chkx As B4XView = chk
pnl.AddView(chkx, .75 * w, 0, .25 *w, 40dip)
pnl.BringToFront
CustomListView1.Add(pnl, text)
End Sub
Private Sub CustomListView1_ItemClick (Index As Int, Value As Object)
Dim pnl As B4XView = CustomListView1.GetPanel(Index)
Dim chk As B4XView = pnl.GetView(1)
If chk.Checked Then
chk.Checked = False
Else
chk.Checked = True
End If
End Sub