I've managed to put switch in CustomListView but I fail to capture what is that changes its state (checked or not). Sender is switchwrapper and not view.
thanks.
thanks.
Can you pls share how you added to list view in code cause when I try I get "view" error"westingenieria, post: 216201, member: 33595"]I've managed to put switch in CustomListView but I fail to capture what is that changes its state (checked or not). Sender is switchwrapper and not view.
thanks.
Sub CreateListItem(Text As String, Width As Int, Height As Int) As Panel
Dim p As Panel
p.Initialize("")
p.Color = Colors.ARGB(180,0,0,0)
Dim chk As Switch
chk.Initialize("chk",0,True)
chk.Gravity = Gravity.CENTER_VERTICAL
Dim lbl As Label
lbl.Initialize("")
lbl.Gravity = Bit.OR(Gravity.CENTER_VERTICAL, Gravity.LEFT)
lbl.Text = Text
lbl.TextSize = 18
lbl.TextColor = Colors.White
'b.Text = "Click"
p.AddView(lbl, 5dip, 2dip, 80%x, Height - 4dip) 'view #0
'p.AddView(chk, 80%x, 2dip, 20%x, Height - 4dip) 'view #1
' p.Left = Width
chk.AddToParent(p,280dip,2dip,100dip,Height - 4dip)
Return p
End Sub
Sub chk_CheckedChange(Checked As Boolean)
Log(Sender)
Dim index As Int
index = clvRutasO.GetItemFromview(Sender) 'HERE ERROR TIPE SWITCHWRAPPER <> VIEW
Dim pnl As Panel
pnl = clvRutasO.GetPanel(index)
Dim chk As Switch
chk = pnl.GetView(1)
If chk.Checked = True Then
'agrega a la lista
lstRutas.Add(clvRutasO.GetValue(index))
Else
'quita de la lista
lstRutas.RemoveAt(lstRutas.IndexOf(clvRutasO.GetValue(index)))
End If
'Msgbox("Item value: " & clvRutasO.GetValue(index) & CRLF & "Check value: " & chk.Checked, "")
End Sub
SwitchID=SwitchID+1
ASwitch.Initialize("HandleBoolean",SwitchID,Property.DefaultValue.ToLowerCase="true")
ASwitch.AddToParent(p,AWidth-AHeight*2,ATop,AHeight*2,AHeight)
Dim v As View
v=ASwitch.switchView 'this gives us the actual view
v.Tag=ASwitch 'this will give us our switch object in the checked event
Sub HandleBoolean_CheckedChange (Value As Boolean,TheSwitch As Object)
Dim r As Reflector
Dim p as view
Dim Aview As View
Dim VSwitch As Switch'this gives us back our switch object
Aview=TheSwitch'gives us a view object to get the Tag
VSwitch=Aview.Tag
r.Target = AView
p=r.RunMethod("getParent") 'this gives you the switches parent
'now you can do pretty much anything you want