iOS Question [B4X] how to get a xCustomListView from a container if it was generated dynamically

Alexander Stolte

Expert
Licensed User
Longtime User
I have a form with a xCustomListView, I now add this form to another xCustomListView as an item.
How can I access this dynamic added xCustomListView now?

This is not working:
As these conventions are rather new, they are not used by some popular custom views such as xCLV. You can set the base panel tag yourself in such cases. For example:
B4X:
Activity.LoadLayout("1")
clv.AsView.Tag = clv
'now we can get the clv with:
Dim c As CustomListView = Activity.GetView(<clv index>).Tag
B4X:
For i = 0 To 10 -1
Dim xpnl_vertical As B4XView = xui.CreatePanel("")
xpnl_vertical.SetLayoutAnimated(0,0,0,100dip,100dip)
xpnl_vertical.LoadLayout("frm_preview_item_1")
      
Dim xclv As CustomListView = xpnl_vertical.GetView(0).tag
xclv.AsView.Tag = xclv

xclv_global.Add(xpnl_vertical,"")
Next
B4X:
Application_Start
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
Application_Active
Error occurred on line: 51 (b4xp_preview)
Method not found: _asview, target:
Stack Trace: (
  CoreFoundation       __exceptionPreprocess + 242
  libobjc.A.dylib      objc_exception_throw + 48
  CoreFoundation       -[NSException initWithCoder:] + 0
  MyAppName           +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 388
  MyAppName           -[B4IShell runMethod:] + 401
  MyAppName           -[B4IShell raiseEventImpl:method:args::] + 1775
  MyAppName           -[B4IShellBI raiseEvent:event:params:] + 1357
  MyAppName           +[B4IDebug delegate:::] + 72
  MyAppName           -[b4i_b4xp_preview _ini:] + 215
  MyAppName           -[ResumableSub_b4xp_preview_B4XPage_Created resume::] + 1988
CoreFoundation       __invoking___ + 140
CoreFoundation       -[NSInvocation invoke] + 305
MyAppName           +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1650
MyAppName           -[B4IShell runMethod:] + 401
MyAppName           -[B4IShell raiseEventImpl:method:args::] + 2361
MyAppName           -[B4IShellBI raiseEvent:event:params:] + 1357
MyAppName           -[B4IDelegatableResumableSub resume::] + 378
MyAppName           -[B4I checkAndRunWaitForEvent:event:params:] + 501
MyAppName           -[B4IShellBI raiseEvent:event:params:] + 1204
MyAppName           __33-[B4I raiseUIEvent:event:params:]_block_invoke + 51
libdispatch.dylib    _dispatch_call_block_and_release + 12
libdispatch.dylib    _dispatch_client_callout + 8
libdispatch.dylib    _dispatch_main_queue_callback_4CF + 1045
CoreFoundation       __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
CoreFoundation       __CFRunLoopRun + 2781
CoreFoundation       CFRunLoopRunSpecific + 567
GraphicsServices     GSEventRunModal + 139
UIKitCore            -[UIApplication _run] + 912
UIKitCore            UIApplicationMain + 101
MyAppName           main + 112
libdyld.dylib        start + 1
???                  0x0 + 1
)
 
Top