Android2个Activity之间传递对象
来源:互联网 发布:mac版pscc2017破解补丁 编辑:程序博客网 时间:2024/05/22 03:40
今天的破事,我们来聊聊在Android中,如果在两个Activity之间传递对象。
首先我们知道利用Intent的putExtra方法放入要传递的数据。看看API上的函数:
Add extended data to the intent.
Add extended data to the intent.
Add extended data to the intent.
Add extended data to the intent.
Add extended data to the intent.
Add extended data to the intent.
Add extended data to the intent.
Add extended data to the intent.
Add extended data to the intent.
Add extended data to the intent.
Add extended data to the intent.
Add extended data to the intent.
Add extended data to the intent.
Add extended data to the intent.
Add extended data to the intent.
Add extended data to the intent.
Add extended data to the intent.
Add extended data to the intent.
Add extended data to the intent.
Add extended data to the intent.
Add extended data to the intent.
Add extended data to the intent.
Add extended data to the intent.
Add extended data to the intent.
Copy all extras in 'src' in to this intent.
Add a set of extended data to the intent.
Add extended data to the intent.
Add extended data to the intent.
Add extended data to the intent.
从上面的方法发现,没有直接放入object的函数。但是有一个
Add a set of extended data to the intent.
没错,我们就是用Intent.putExtras(Bundle extras)来传递对象。生成Bundle对象时有两种放入对象的方式一是Bundle.putSerializable(Key,Object);
二是采用Bundle.putParcelable(Key, Object);
其中前面一种方法中的Object要实现Serializable接口,后面一种方法中的Object要实现Parcelable接口。
结合我的项目来说下。首先在你跳转前的Activity设置bundle,这里我是想从
说明,这里的AccountInfo需要实现Serializable接口。
最后我们在PersonCenterActivity中onCreate方法中用下面的方法取得account对象
Parcelable 方式和这基本类似,这里不展开讲了。注意要传递的对象需要实现implements Parcelable。
接受对象:
是不是很简单,其实就这点破事。
阅读全文
0 0
- Android2个Activity之间传递对象
- Android2个Activity之间传递对象
- Android2个Activity之间传递对象
- 【Android开发那点破事】Android2个Activity之间传递对象
- 【Android开发那点破事】Android2个Activity之间传递对象
- activity之间传递对象
- activity之间传递对象
- Activity之间传递对象
- Activity之间传递类对象
- Activity之间的 对象传递
- Activity之间传递类对象
- Activity之间传递类对象
- Activity之间传递类对象
- Android Activity 之间传递对象
- android Activity之间传递对象
- Activity之间传递类对象
- Activity之间传递类对象
- Activity之间传递类对象
- vs2015 新建ADO.NET 实体数据模型向导,选择MySql数据库连接后点击下一步就闪退
- neo4j 服务器
- 内核程序的基本框架
- 大数据告诉你,中国有2亿单身狗
- 561. Array Partition I
- Android2个Activity之间传递对象
- nginx学习随笔--use
- 2017秋招笔试C++真题
- python codecs.open视\u2028字符为换行符
- C++文件读写详解(ofstream,ifstream,fstream)还有简单使用
- SOAPfuse 安装
- 在线解压缩获取文件列表名
- Retrofit
- JAVAFX安装