Android Question HashMap and include

EduardoElias

Well-Known Member
Licensed User
Longtime User
I am trying to use:

B4X:
private static Map convertToMap(HashMap<?, ?> javaMap) {
     Map m = new Map();
     m.Initialize();
     for (Entry<?, ?> e : javaMap.entrySet()) {
       m.Put(e.getKey(), e.getValue());
     }
     return m;
   }

However I am getting

java:721: error: cannot find symbol
Map m = new Map();
^

What is the include that I need?

Already doing this:
import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.*;
 

DonManfred

Expert
Licensed User
Longtime User
Where do you put this code?
Based on the sub signature he is using it inside inline java or java i guess
B4X:
private static Map convertToMap(HashMap<?, ?> javaMap) {
}
 
Upvote 0

EduardoElias

Well-Known Member
Licensed User
Longtime User
It will be easier to help if you provide more context. Where do you put this code?

Based on the error it treats the Map as java.util.Map.

thank you, Solved:

B4X:
import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.*;
import anywheresoftware.b4a.objects.collections.*;

import android.app.Activity;
import android.content.Context;

import java.util.HashMap;
import java.util.List;

public static Map convertToMap(HashMap<String, String> javaMap) {
     Map m = new Map();
     m.Initialize();
     for (HashMap.Entry<String, String> e : javaMap.entrySet()) {
       m.Put(e.getKey(), e.getValue());
     }
     return m;
}

<more code>
 
Upvote 0
Top