虽然知识非常基础,但我觉得无论是否是难点,即便非常简单的知识,及时写出来对知识积累都是有好处的。今天写一下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");
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。