I have a Custom ListView control in which each panel contains a Switch button. I want to be able to scroll through all the buttons in the list and get their value. I tried using the following code, but I get an error message.
Error message:
Error occurred on line: 153 (Grafice) (but = v)
Expected: UISwitch, object type: B4IPanelView
Stack Trace: (
CoreFoundation DA838E75-6B30-360E-9661-C4800A7E1BF6 + 1227168
libobjc.A.dylib objc_exception_throw + 56
CoreFoundation DA838E75-6B30-360E-9661-C4800A7E1BF6 + 135252
xBeam -[B4IObjectWrapper setObject:] + 276
CoreFoundation DA838E75-6B30-360E-9661-C4800A7E1BF6 + 1252752
CoreFoundation DA838E75-6B30-360E-9661-C4800A7E1BF6 + 7120
xBeam +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1608
xBeam -[B4IShell runVoidMethod] + 232
xBeam -[B4IShell raiseEventImpl:method:args::] + 1800
xBeam -[B4IShellBI raiseEvent:event
arams:] + 1580
xBeam __33-[B4I raiseUIEvent:event
arams:]_block_invoke + 60
libdispatch.dylib 3A5DB4E0-BC24-375D-897E-51E6CF7D6304 + 374288
libdispatch.dylib 3A5DB4E0-BC24-375D-897E-51E6CF7D6304 + 377220
libdispatch.dylib 3A5DB4E0-BC24-375D-897E-51E6CF7D6304 + 57808
CoreFoundation DA838E75-6B30-360E-9661-C4800A7E1BF6 + 693188
CoreFoundation DA838E75-6B30-360E-9661-C4800A7E1BF6 + 672696
CoreFoundation CFRunLoopRunSpecific + 464
GraphicsServices GSEventRunModal + 104
UIKitCore UIApplicationMain + 1936
xBeam main + 124
libdyld.dylib E1637502-BFCB-3BBC-B3E1-CCF78617E0E4 + 5216
)
What am I not doing well?
B4X:
Dim selectedValues As List
For Each v As B4XView In pg.RootPanel.GetAllViewsRecursive
Dim tag As String = v.Tag
If tag.StartsWith("val") Then
'each switch button Tag is like "val..."
Dim but As Switch
but.Initialize("")
but = v
If but.Value = True Then
selectedValues.Add(tag)
End If
End If
Next
Error message:
Error occurred on line: 153 (Grafice) (but = v)
Expected: UISwitch, object type: B4IPanelView
Stack Trace: (
CoreFoundation DA838E75-6B30-360E-9661-C4800A7E1BF6 + 1227168
libobjc.A.dylib objc_exception_throw + 56
CoreFoundation DA838E75-6B30-360E-9661-C4800A7E1BF6 + 135252
xBeam -[B4IObjectWrapper setObject:] + 276
CoreFoundation DA838E75-6B30-360E-9661-C4800A7E1BF6 + 1252752
CoreFoundation DA838E75-6B30-360E-9661-C4800A7E1BF6 + 7120
xBeam +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1608
xBeam -[B4IShell runVoidMethod] + 232
xBeam -[B4IShell raiseEventImpl:method:args::] + 1800
xBeam -[B4IShellBI raiseEvent:event
xBeam __33-[B4I raiseUIEvent:event
libdispatch.dylib 3A5DB4E0-BC24-375D-897E-51E6CF7D6304 + 374288
libdispatch.dylib 3A5DB4E0-BC24-375D-897E-51E6CF7D6304 + 377220
libdispatch.dylib 3A5DB4E0-BC24-375D-897E-51E6CF7D6304 + 57808
CoreFoundation DA838E75-6B30-360E-9661-C4800A7E1BF6 + 693188
CoreFoundation DA838E75-6B30-360E-9661-C4800A7E1BF6 + 672696
CoreFoundation CFRunLoopRunSpecific + 464
GraphicsServices GSEventRunModal + 104
UIKitCore UIApplicationMain + 1936
xBeam main + 124
libdyld.dylib E1637502-BFCB-3BBC-B3E1-CCF78617E0E4 + 5216
)
What am I not doing well?