首页 > 其他 > 详细

Fragment与Activity交互(使用Bundle)

时间:2015-08-29 00:37:06      阅读:306      评论:0      收藏:0      [点我收藏+]
将需要传输的数据封装在一个Bundle对象里,然后将该Bundle对象通过
fragment.setArguments()放到fragment内.
Bundle arguments = new Bundle();
arguments.putInt("int", 10);
Fragment fragment = new Fragment();
fragment.setArguments(arguments);
getFragmentManager().beginTransaction()
.replace(R.id.book_detail_container, fragment)
.commit();

在Fragment的回调函数内取出Bundle对象

Bundle bundle = getArguments();

Fragment与Activity交互(使用Bundle)

原文:http://www.cnblogs.com/vinozly/p/4768166.html

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