I'm successfully using CustomListView and it's great. However, I've added a SwitchView (class) as one of the views, and although it appears nicely on the display, I can't capture the CheckedChange event. This is the CheckedChange code:
B4X:
Sub sw_CheckedChange(Checked As Boolean)
Dim index As Int
index = clv.GetItemFromView(Sender)
Dim pnl As Panel
pnl = clv.GetPanel(index)
Dim sv As SwitchView
sv = pnl.GetView(2)
Msgbox("Switch: " & index & CRLF & "Position: " & sv.Checked, "")
End Sub
The problem is that SwitchView is not recognized as an Android view so it crashes at sv=pnl.GetView(2). Is there something I should be doing to eliminate or get around this problem, or is a class like Switchview just not usable with CustomListView?
Sub sw_CheckedChange(Checked As Boolean)
Dim index As Int
index = clv.GetItemFromView(Sender)
Dim pnl As Panel
pnl = clv.GetPanel(index)
For Each v As View In pnl.GetAllViewsRecursive
Log(v)
Next
'Dim sv As SwitchView
'sv = pnl.GetView(2)
'Msgbox("Switch: " & index & CRLF & "Position: " & sv.Checked, "")
End Sub
Sub sw_CheckedChange(Checked As Boolean)
Dim index As Int
index = clv.GetItemFromView(Sender)
Dim pnl As Panel
pnl = clv.GetPanel(index)
For Each v As View In pnl.GetAllViewsRecursive
Log(v)
If v Is SwitchView Then
Dim sv As SwitchView = v
' do whatever
End If
Next
'Dim sv As SwitchView
'sv = pnl.GetView(2)
'Msgbox("Switch: " & index & CRLF & "Position: " & sv.Checked, "")
End Sub
Sub sw_CheckedChange(Checked As Boolean)
Dim index As Int
index = clv.GetItemFromView(Sender)
Dim pnl As Panel
pnl = clv.GetPanel(index)
For Each v As View In pnl.GetAllViewsRecursive
Log(v)
If v Is SwitchView Then
Dim sv As SwitchView = v
' do whatever
End If
Next
'Dim sv As SwitchView
'sv = pnl.GetView(2)
'Msgbox("Switch: " & index & CRLF & "Position: " & sv.Checked, "")
End Sub
Thanks Manfred. Yes, SwitchView is definitely the 3rd item. If I use a CheckBox in place of SwitchView, all works perfectly. I have a feeling that the problem is similar to the one discussed here and I will play with Erel's suggested code to see if I can make it work (but will have to wait until after the holidays!). Thanks for your input and have a great Holiday Season!
Thanks Manfred. Yes, SwitchView is definitely the 3rd item. If I use a CheckBox in place of SwitchView, all works perfectly. I have a feeling that the problem is similar to the one discussed here and I will play with Erel's suggested code to see if I can make it work (but will have to wait until after the holidays!). Thanks for your input and have a great Holiday Season!