在捆绑的Andr​​oid HashMap的? [英] Android HashMap in Bundle?

查看:86
本文介绍了在捆绑的Andr​​oid HashMap的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

这篇关于在捆绑的Andr​​oid HashMap的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆