将HashMap从一个活动传递到另一个活动,android

将HashMap从一个活动传递到另一个活动,android,android,Android,我正在编写一个android应用程序来显示附近的位置。然后我将其存储在如下的hashmap列表中 List<HashMap<String, String>> places = null; 在下一个活动中,我这样做了: protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout

我正在编写一个android应用程序来显示附近的位置。然后我将其存储在如下的hashmap列表中

List<HashMap<String, String>> places = null;
在下一个活动中,我这样做了:

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.list_airports);
        Bundle extras = getIntent().getExtras();
        String[] places=extras.getStringArray(Intent.EXTRA_TEXT);
但是putExtra方法不接受
List

使用
putExtra(String,Serializable)
在Intent中传递它,并使用
getSerializableExtra(String)
方法检索它

另外,请使用
ArrayList
而不是
List
使用intent.putExtra(字符串,可序列化)-请参阅。 i、 e

在接收活动中使用

HashMap<String, String> places = (HashMap<String, String>) intent.getSerializableExtra("placesHashMap");
hashMapplaces=(HashMap)intent.getSerializableExtra(“placesHashMap”);
什么是

当前类的可序列化截图

1。将意图从上下文类传递到新类

Bundle b=getIntent.getExtra();
 if(b!=null)
   {
     yourhasmaplist=b.getSerializableExtra("key"); 
   }

您是对的,putExtra方法不接受列表。。。那么问题是什么呢?@Scott问题是:有没有办法通过“名单”
HashMap<String, String> places = (HashMap<String, String>) intent.getSerializableExtra("placesHashMap");
HashMap<String, String> hashMap= adapter.getItem(position);
Intent intent = new Intent(OneActivity.this, SecondActivity.class);
intent.putExtra("key", value);
startActivity(intent);
Bundle b=getIntent.getExtra();
 if(b!=null)
   {
     yourhasmaplist=b.getSerializableExtra("key"); 
   }