Beginner question concerning lists and custom types

Disco

Member
Licensed User
Longtime User
I have the following code in a For loop:

B4X:
If aMarkerIDs.IndexOf(m.Get("id")) <> -1 Then
      
aMarker.id = m.Get("id")
' plus other attributes beside ID

mapMarkers.Add(aMarker)

End If

aMarker is a custom type which is then added to a list called mapMarkers. I'm guessing that aMarker is being added by reference because I end up with mapMarkers containing items all with the same value as the last aMarker that was added.

How do I store each aMarker as separate instance? Is there a "New" keyword in B4A or something similar?

Thanks! :)
 
Top