I know this seems a pretty basic question and I don't really know whats going on. Searched the forums for quite a while tough...
I am trying to pass a map object to a function that uses items of the map like this:
now the argument that gets passed emerges from, an iteration over another map that holds maps like the one thats supposed to get passed:
What happens is that the program goes crashing with that:
"java.lang.ClassCastException: java.lang.String cannot be cast to anywheresoftware.b4a.objects.collections.Map$MyMap"
I tried a bunch of tricks like passing it as "object" and then assigning it to an initialized temporary map but nothing works.
I have to admit I'm neither very skilled in nor very fond of OOP, I just recently started to get deeper into OOP using B4J to at least keep an open mind about it, so please be gentle.
Help is much appreciated!
Thank you guys
I am trying to pass a map object to a function that uses items of the map like this:
B4X:
Private Sub AddToList(event As Map)
Dim string1 As String
string1 = event.Get("Name") & " | "
string1 = string1 & event.Get("Time") & " | "
string1 = string1 & NumberFormat(Bit.ToBinaryString(event.Get("Days")),8,0) & " | "
string1 = string1 & event.Get("MQTTTopic") & " | "
string1 = string1 & event.Get("MQTTVal")
Main.Eventlistview.Items.Add(string1)
End Sub
now the argument that gets passed emerges from, an iteration over another map that holds maps like the one thats supposed to get passed:
B4X:
For i=0 To eventdb.Size-1
AddToList(eventdb.GetValueAt(i))
Next
What happens is that the program goes crashing with that:
"java.lang.ClassCastException: java.lang.String cannot be cast to anywheresoftware.b4a.objects.collections.Map$MyMap"
I tried a bunch of tricks like passing it as "object" and then assigning it to an initialized temporary map but nothing works.
I have to admit I'm neither very skilled in nor very fond of OOP, I just recently started to get deeper into OOP using B4J to at least keep an open mind about it, so please be gentle.
Help is much appreciated!
Thank you guys