任何人都可以帮助我通过 Intent 发送hashmap
并在其他 Activity 上接收它第一个参数是字符串,第二个参数是字符串列表无法找到任何正在努力或尝试发送的人这是通过我也在尝试的方式实现的 Intent
Map<String, List<String>> map = new hashmap<>();
最佳答案
您必须使用可序列化并通过 Intent 传递 map 。 数据发送器的代码示例如下:
Map map = new HashMap<String,List<String>>();
List<String> l1 = new ArrayList();
l1.add("HEllo");
l1.add("John");
l1.add("Michael");
l1.add("Jessy");
map.put("Names" , l1);
Intent intent = new Intent("CurrentActivityName".this, "DestinationActivityName".class);
intent.putExtra("Map",(Serializable) map);
startActivity(intent);
接收者代码:
Map map = new HashMap<String,List>();
map = (Map) getIntent().getSerializableExtra("Map");
现在您可以使用名为 map 的变量访问数据。
关于java - 如何通过 Intent 发送 Map<String, List<String>>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53167051/