The Goal is to Add MapFragment with Customlistview while using LazyLoading. After the mapfragment is ready, add a marker to all of the maps.
The Problem is that at VisibleRangeChanged, mfclvorders_Ready is called for only the last MapFragment. Therefore, All the maps except the last are left blank.
The Following code populates the customlistview by looping through a map 'mapor':
Code for VisibleRangeChanged:
MapFragment is not a view(does not return a base panel). So, calling clvorders.GetItemFromView(mfclvorders) outside the VisibleRangeChanged is also not possible.
How to solve this problem?
The Problem is that at VisibleRangeChanged, mfclvorders_Ready is called for only the last MapFragment. Therefore, All the maps except the last are left blank.
The Following code populates the customlistview by looping through a map 'mapor':
B4X:
For j = 0 To mapor.Size - 1
Dim CLI As CreateListItemClvOrders:CLI.Initialize
Dim IncomingMapnext As Map=mapor.GetValueAt(j)
CLI.maporders=IncomingMapnext
Dim xui As XUI
Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(300, 0, 0, clvorders.AsView.Width, 50%y)
clvorders.Add(p, CLI)
Next
Code for VisibleRangeChanged:
B4X:
Dim ExtraSize As Int = 1
For i = 0 To clvorders.GetSize-1
Dim p As B4XView = clvorders.GetPanel(i)
If i > FirstIndex - ExtraSize And i < LastIndex + ExtraSize Then
If p.NumberOfViews = 0 Then
Dim CLI As CreateListItemClvOrders = clvorders.GetValue(i)
p.LoadLayout("clvorders")
Wait For mfclvorders_Ready
Log("clvorders_VisibleRangeChanged"&i)
Dim maptemp As Map=CLI.maporders
mfclvorders.GetMap.AddMarker(maptemp.Get("latitude"), bllon=maptemp.Get("longitude"), "Pickup Point").Snippet="Pickup Point"
Dim cp As CameraPosition:cp.Initialize(maptemp.Get("latitude"), bllon=maptemp.Get("longitude"), 10)
mfclvorders.GetMap.AnimateCamera(cp)
End If
Else
'not visible
If p.NumberOfViews > 0 Then
p.RemoveAllViews '<--- remove the layout
End If
End If
Next
MapFragment is not a view(does not return a base panel). So, calling clvorders.GetItemFromView(mfclvorders) outside the VisibleRangeChanged is also not possible.
How to solve this problem?
Last edited: