码迷,mamicode.com
首页 > 其他好文 > 详细

Fragment与Activity交互(使用Bundle)

时间:2015-08-29 00:38:53      阅读:167      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!