I have tried this code but it is not working , I get "java.lang.ClassCastException: class anywheresoftware.b4a.objects.collections.Map cannot be cast to class anywheresoftware.b4a.objects.collections.Map$MyMap (anywheresoftware.b4a.objects.collections.Map and anywheresoftware.b4a.objects.collections.Map$MyMap are in unnamed module of loader 'app')", does anyone know where the problem lies ?
Is there another way to return a b4x map from java ?
test:
Sub Button1_Click
Dim mp As Map=GetJavaMap
Dim s As Int=mp.Size
xui.MsgboxAsync("Size", s)
End Sub
Public Sub GetJavaMap() As Map
Dim m As Map
m.Initialize
Dim mo As JavaObject = Me
m=mo.RunMethod("getMyMap", Null)
Return m
End Sub
#if java
import java.lang.reflect.*;
import java.io.Console;
import anywheresoftware.b4a.*;
import anywheresoftware.b4a.objects.collections.Map;
public static Map getMyMap()
{
Map mpPrt = new Map();
mpPrt.Initialize();
Map mp = new Map();
mp.Initialize();
mp.Put(1,"Test 1");
mp.Put(2,"Test 2");
mpPrt.Put(1,mp);
mp.Initialize();
mp.Put(3,"Test 3");
mp.Put(4,"Test 4");
mpPrt.Put(2,mp);
return mpPrt;
}
#End If
Is there another way to return a b4x map from java ?