传递数据
Map
Android开发默认情况下,通过Bundle bundle=new Bundle();传递值是不能直接传递map对象的,解决办法:
第一步:封装自己的map,实现序列化即可
/**
* 序列化map供Bundle传递map使用
* Created on 13-12-9.
*/
public class SerializableMap implements Serializable {
private Map<String,Object> map;
public Map<String, Object> getMap() {
return map;
}
public void setMap(Map<String, Object> map) {
this.map = map;
}
}
第二步:传递数据:
Intent intent=new Intent(ListViewActivity.this,UpdateWatchActivity.class);
//传递数据
final SerializableMap myMap=new SerializableMap();
//将map数据添加到封装的myMap中
myMap.setMap(map);
Bundle bundle=new Bundle();
bundle.putSerializable("map", myMap);
intent.putExtras(bundle);
第三步:接收数据:
Bundle bundle = getIntent().getExtras();
SerializableMap serializableMap = (SerializableMap) bundle.get("map");
到此数据就能在通过map传递和使用了。
引用:
android传递数据bundle封装传递map对象 - EDIAGD的个人页面 - 开源中国社区
Android 关闭多个视图Intent.FLAG_ACTIVITY_CLEAR_TOP用法 - LVXIANGAN的专栏 - 博客频道 - youkuaiyun.com
http://blog.youkuaiyun.com/lvxiangan/article/details/42120951