Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/179.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何发送列表<;HashMap<;字符串,字符串>&燃气轮机;将列表添加到其他活动_Android_List_Hashmap - Fatal编程技术网

Android 如何发送列表<;HashMap<;字符串,字符串>&燃气轮机;将列表添加到其他活动

Android 如何发送列表<;HashMap<;字符串,字符串>&燃气轮机;将列表添加到其他活动,android,list,hashmap,Android,List,Hashmap,我试图将列表>列表发送到另一个活动。我试了很多方法,但都做不到。请帮忙 您可以使用Intent hashMap.put("key", "value"); Intent intent = new Intent(this, otherActivity.class); intent.putExtra("mapkey", hashMap); startActivity(intent); 编辑: 为其他活动赋予价值 Intent intent = getIntent(); HashMap

我试图将列表>列表发送到另一个活动。我试了很多方法,但都做不到。请帮忙

您可以使用
Intent

hashMap.put("key", "value");
Intent intent = new Intent(this, otherActivity.class);
intent.putExtra("mapkey", hashMap);
startActivity(intent);
编辑:

为其他活动赋予价值

    Intent intent = getIntent();
    HashMap<String, String> hashMap = (HashMap<String, String>) intent.getSerializableExtra("mapkey"); 
    intent.getSerializableExtra("mapkey");
Intent-Intent=getIntent();
HashMap HashMap=(HashMap)intent.getSerializableExtra(“mapkey”);
getSerializableExtra(“mapkey”);
编辑(将其转换回列表)尝试以下操作:

HashMap<String, String> map = new HashMap<String, String>();
List<String> hashMap = new ArrayList<String>(map.values());
HashMap map=newhashmap();
List hashMap=newarraylist(map.values());

快乐编码

尝试将其作为arraylist发送。我尝试过,但无法将其发送。如果您的列表是arraylist,则它是可序列化的。很抱歉,它不是arraylist。您的数据表示什么?您将如何在第二个活动中接收此信息?但现在我们有了一个hashmap,如何将其转换为列表?列表列表不起作用。关于您的信息,它给出了一个错误“类型意图中的方法putExtra(String,boolean)不适用于参数(String,List)”,请尝试,
List hashMap=(List