【发布时间】:2014-03-14 13:00:04
【问题描述】:
我想通过意图传递 HashMap 对象。我的 Hashmap 包含字符串和列表。 HashMap> listDataChild;我想将 listDataChild 传递给下一个活动?
【问题讨论】:
标签: android
我想通过意图传递 HashMap 对象。我的 Hashmap 包含字符串和列表。 HashMap> listDataChild;我想将 listDataChild 传递给下一个活动?
【问题讨论】:
标签: android
试试下面的代码:
Intent intent=new Intent(CURRENT CLASS.this, CLASS TO CALL.class);
intent.putExtra("test", YOUR HASHMAP);
startActivity(intent);
在另一个 Activity 中获取如下数据:
HashMap<String, List<String>> data=(HashMap<String, List<String>>) this.getIntent().getSerializableExtra("test");
【讨论】:
将其作为Bundle 的一部分附加到 Intent。 HashMap 是 Serializable,因此它可以在 Bundle 或 Extra 中工作。
【讨论】: