I am trying to assign a map data type to a label tag property. In the label click event, creating a map type. however the label.tag property is shown as an empty string.
the same kind of code works fine in a B4J project.
can someone help me ?
error thrown in b4a
java.lang.ClassCastException: java.lang.String cannot be cast to anywheresoftware.b4a.objects.collections.Map$MyMap
at newkot.com.posandtables._lbltable_click(posandtables.java:826)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:170)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:166)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:6261)
at android.widget.TextView.performClick(TextView.java:11159)
at android.view.View$PerformClick.run(View.java:23752)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6776)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)
B4X:
'in jobdone i am initialising a mapvariable and moving data
Dim mTable As Map
mTable.Initialize
mTable.Put(0,row(3)) ' occupied / vacant
mTable.Put(1,row(7)) ' unsettled
mTable.Put(2,row(11)) ' hold
mTable.Put(3,row(0)) ' tablepckey
mTable.Put(4,row(4)) ' captain name
mTable.Put(5,row(5)) ' waiter name
mTable.Put(6,row(6)) ' pax
mTable.Put(7,row(9)) ' captain key
mTable.Put(8,row(10)) ' waiter key
lblTable.Text=row(1)
lblTable.Tag=mTable
Log("tag size " & mTable.Size) ' result 9
Log("Tag " & lblTable.Tag) ' result {0=false, 1=false, 2=false, 3=335, 4=, 5=, 6=1, 7=15, 8=25}
Sub lblTable_Click
Dim l As Label
l=Sender
Log("text " & l.Text) ' result 14B
Log("tag " & l.Tag) ' result tag - no value
Dim m As Map
m=l.Tag ' HERE I GET ERROR
the same kind of code works fine in a B4J project.
can someone help me ?
error thrown in b4a
java.lang.ClassCastException: java.lang.String cannot be cast to anywheresoftware.b4a.objects.collections.Map$MyMap
at newkot.com.posandtables._lbltable_click(posandtables.java:826)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:170)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:166)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:6261)
at android.widget.TextView.performClick(TextView.java:11159)
at android.view.View$PerformClick.run(View.java:23752)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6776)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)