android.os.Message
使用 Bundle
通过它的 sendMessage 方法发送。因此,是否可以将 HashMap
放入 Bundle
中?
最佳答案
尝试:
Bundle extras = new Bundle();
extras.putSerializable("HashMap",hashMap);
intent.putExtras(extras);
在第二个 Activity 中
Bundle bundle = this.getIntent().getExtras();
if(bundle != null) {
hashMap = bundle.getSerializable("HashMap");
}
因为 Hashmap默认实现 Serializable
所以你可以在 Bundle 中使用 putSerializable
传递它,并使用 getSerializable
关于Bundle中的Android HashMap?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11452859/