Intent
来源:互联网 发布:帝国源码 编辑:程序博客网 时间:2024/06/16 14:30
传递数据
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的专栏 - 博客频道 - CSDN.NET
http://blog.csdn.net/lvxiangan/article/details/42120951
0 0
- intent
- Intent
- Intent
- Intent
- intent
- Intent
- intent
- Intent
- Intent
- Intent
- Intent
- Intent
- Intent
- intent
- Intent
- intent
- Intent
- intent
- 单源最短路HDU2544
- 高并发的网站架构
- Retrofit 2.0文件上传
- 【JavaScript】入门概念
- JDBC连接数据库(1)
- Intent
- 第十五周项目一 阅读下面程序,解释运行结果(6)
- MyBatis批量插入数据
- Android学习记录(一) 重拾Activity
- C语言之define
- class文件校验器分成四趟独立的扫描来完成校验。
- 最大二叉搜索子树
- php的构造函数理解
- 三层架构