Fragment与FragmentAcitvity间的传值

Fragment与FragmentAcitvity间的传值


FragmentActivity中传值

Bundle bundle=new Bundle();

        bundle.putSerializable(“companyInfor”, company);

 companyExhFragment.setArguments(bundle);


Fragment中接收值

Bundle bundle=getArguments();
if(bundle!=null)//接收从activity中传来的值
   company=(RecommendCompanyResult) bundle.getSerializable(”companyInfor“);


注意:一定要新建一个Bundle对象,不能引用其他页面传来的Bundle 
 

 

原文地址:https://www.cnblogs.com/james1207/p/3424138.html