Fragment与Activity交互(使用Bundle)

将需要传输的数据封装在一个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();
原文地址:https://www.cnblogs.com/vinozly/p/4768166.html