在捆绑的Andr​​oid HashMap的?Andr、oid、HashMap

2023-09-05 08:20:27 作者:知途也知你

android.os.Message 使用捆绑送与它的sendMessage法。因此,是否有可能把一个的HashMap 捆绑

The android.os.Message uses a Bundle to send with it's sendMessage-method. Therefore, is it possible to put a HashMap inside a Bundle?

感谢名单提前, 马库斯

Thanx in advance, Marcus

推荐答案

尝试为:

Bundle extras = new Bundle();
extras.putSerializable("HashMap",Hash_Map);
intent.putExtras(extras);

和第二活动

Bundle bundle = this.getIntent().getExtras();
 if(bundle!=null){
   Hash_Map= bundle.getSerializable("HashMap");

监守的Hashmap 通过默认工具序列化这样你就可以使用它传递 putSerializable 的包,并使用在其他活动获得 getSerializable

becuase Hashmap by default implements Serializable so you can pass it using putSerializable in Bundle and get in other activity using getSerializable