intent传递数据方法总结
来源:互联网 发布:最新的编程语言 编辑:程序博客网 时间:2024/05/16 07:14
传递正常数据:
1:intent 传递:
Intent intent = new Intent(context, HomeDetailActivity.class);
intent.putExtra(“url”,newest.url);
Log.e(“jxf”,”home页列表点击位置url”+newest.url);
context.startActivity(intent);
getActivity().overridePendingTransition(R.anim.push_left_in, R.anim.push_left_out);
获取:Intent intent=getIntent();url=intent.getStringExtra("url");
2:intent 封装bundle:bundle传递数据
Intent intent=new Intent(context, ChannelActivity2.class);Bundle bundle = new Bundle();bundle.putInt("teacherId", contents.get(position - 1).teacherId);bundle.putString("portraitUrlSmall", contents.get(position - 1).portraitUrlSmall);bundle.putString("portraitUrlBig", contents.get(position - 1).portraitUrlBig);bundle.putString("nickname", contents.get(position - 1).nickname);bundle.putString("catgoryName", contents.get(position - 1).catgoryName);bundle.putString("catgoryId", contents.get(position-1).catgoryId);bundle.putInt("catgoryIdMark", catgoryId);intent.putExtras(bundle);context.startActivity(intent);getActivity().overridePendingTransition(R.anim.push_left_in, R.anim.push_left_out);获取:Bundle bundle=getIntent().getExtras();teacherId=bundle.getInt("teacherId");portraitUrlSmall=bundle.getString("portraitUrlSmall");portraitUrlBig=bundle.getString("portraitUrlBig");nickname=bundle.getString("nickname");catgoryNames=bundle.getString("catgoryName");catgoryIds=bundle.getString("catgoryId");catgoryIdMark= bundle.getInt("catgoryIdMark");
3:intent传递序列化对象集合
Intent intent=new Intent(SubscriptionActivity.this,PlayActivity.class);
intent.putExtra(“list”, (Serializable) lessons);
获取:lessons= (ArrayList<MusicLesson>) getIntent().getSerializableExtra("list");
4:intent传递序列化对象集合和其他数据
Intent intent=new Intent(SubscriptionActivity.this,PlayActivity.class);
Bundle bundle=new Bundle();
bundle.putString(“portraitUrlSmall”, portraitUrlSmall);
bundle.putString(“nickname”, nickname);
bundle.putInt(“itemposition”, position);
intent.putExtras(bundle);
intent.putExtra(“list”, (Serializable) lessons);
startActivityForResult(intent, 500);
overridePendingTransition(R.anim.push_left_in, R.anim.push_left_out);
获取:Bundle bundle = getIntent().getExtras();portraitUrlSmall=bundle.getString("portraitUrlSmall");nickname=bundle.getString("nickname");itemposition=bundle.getInt("itemposition");lessons= (ArrayList<MusicLesson>) getIntent().getSerializableExtra("list");title=lessons.get(itemposition).title;categoryName=lessons.get(itemposition).categoryName;pictureUrlSmall=lessons.get(itemposition).pictureUrlSmall;url=lessons.get(itemposition).url;initCurrentposition=lessons.get(itemposition).currentposition;
5:intent封装bundle传递序列化对象
Intent intent = new Intent(context, DetailofHistoryTicketActivity.class);
TicketInfoBean ticketInfoBean = ticketInfoBeans.get(position-1);
Log.e(“jxf”,”打印传递的字符串对象ordersTicketDetailProtocolList+++++++”+ticketInfoBean.ordersTicketDetailProtocolList);
Bundle bundle=new Bundle();
bundle.putSerializable(“ticketInfoBean”, ticketInfoBean);
intent.putExtras(bundle);
context.startActivity(intent);
getActivity().overridePendingTransition(R.anim.push_left_in, R.anim.push_left_out);
获取:TicketInfoBean ticketInfoBean= (TicketInfoBean) getIntent().getSerializableExtra("ticketInfoBean");序列化的传递:值是传递对象的一份copy:并不是和上页传递过来的对象是同一对象:比如:改变对象,另一页的并不会发生改变。
- intent传递数据方法总结
- android笔记 Intent传递数据的方法
- Android - Intent - 传递数据
- Intent传递数据
- intent数据传递问题
- Intent传递的数据
- Intent 数据传递
- Intent传递数据
- Android - Intent - 传递数据
- Intent 传递数据
- Intent数据传递
- Intent数据传递
- Intent数据传递
- intent 传递 数据
- Intent的数据传递
- Intent传递集合数据
- Intent数据传递
- Intent数据传递
- 创建 virtualbox client com 失败
- uva442
- 如何在svn中提交一个被重命名的旧项目
- 常见排序的时间复杂度和空间复杂度
- 友元函数
- intent传递数据方法总结
- 关于MotionEvent的小知识
- poj 3278--- Catch That Cow
- 练习1-a
- VS2010工具箱缺少Microsoft Communications Control组件解决方法
- Hadoop MapReduce程序的模板框架
- Mybatis #和$
- 用cout输出指定位数小数方法
- 如何导出内存镜像