fragment中:
public static TypeFragment newInstance(String Type)
{
Bundle bundle=new Bundle();
bundle.putSerializable("id", Type);
TypeFragment fragment=new TypeFragment();
fragment.setArguments(bundle);
return fragment;
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle bundle = this.getArguments();
if(bundle != null){
type = bundle.getString("id");
}
}
Activity:
fram1=new TypeFragment().newInstance(id);
fragmentlist.add(fram1);