首页 > 其他 > 详细

Intent的数据传递

时间:2015-12-07 00:39:27      阅读:164      评论:0      收藏:0      [点我收藏+]

虽然知识非常基础,但我觉得无论是否是难点,即便非常简单的知识,及时写出来对知识积累都是有好处的。今天写一下Intent的数据传递。

发送端:

//创建Intent
Intent intent = new Intent();

//把需要传递的内容放进Intent
intent.putExtra("id", waitInfo.id);
intent.putExtra("warnning_star", warnning_star);
intent.putExtra("fengxlx", waitInfo.fengxlx);
intent.putExtra("chehao", waitInfo.chehao);
intent.putExtra("content", waitInfo.content);
intent.putExtra("time", waitInfo.time);

//设置即将要启动的Activity
intent.setClass(getActivity(), ZaiTuYuJing_FengXCL_XiangXXX_Activity.class);

//跳转
startActivity(intent);

接收端:

//接收Intent
Intent intent = getIntent();

//取出捆绑数据
Bundle bundle = intent.getExtras();

//从数据中根据key取出所需内容
int index = Integer.parseInt(bundle.getString("id"));
String chehao = bundle.getString("chehao");
String content = bundle.getString("content");
String time = bundle.getString("time");


本文出自 “移动平台开发” 博客,请务必保留此出处http://liuxudong1001.blog.51cto.com/10877072/1720155

Intent的数据传递

原文:http://liuxudong1001.blog.51cto.com/10877072/1720155

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!