Android Question Problem with Tags and Maps (collections)

FrankBerra

Active Member
Licensed User
Longtime User
Hello forum
I was used to use tags in custom views like this
B4X:
Public Sub setTag1(ValoreTag1 As Object)
   Tag1 = ValoreTag1
End Sub

Public Sub getTag1 As Object
   Return Tag1
End Sub

Until now i was setting tags with simple strings and everything worked as expected.
Now i need to set a map (collection) as tag.
I set it with:
B4X:
dim m as map
m.initialize
m.put("x", "123")
CLV.Tag1 = m

but when i retrieve the tag with
B4X:
Sub Generic
dim m as map
m = CLV.Tag1

CallSubDelayed2(Me, "Elaborate", m)
End sub

Sub Elaborate(Values as map)  '<--- Error here

End Sub
i expect to get a map but when use it, an error says to me that:
B4X:
argument 1 has type anywheresoftware.b4a.objects.collections.Map, got anywheresoftware.b4a.objects.collections.Map$MyMap

Where i am wrong?
 

DonManfred

Expert
Licensed User
Longtime User
Try it this way
B4X:
Sub Elaborate(Values as Object)
dim m as map = Values

End Sub
 
Upvote 0
Top