在fragment里边 添加一个方法
前提:将对象类型的数据 全部 序列化,基本类型的有自己的方法
public static QuestionFragment getInstance(ChooseTotalModel model,String category_id, int position)
{
QuestionFragment q = new QuestionFragment();//创建一个fragment
Bundle bundle = new Bundle(); //利用 Bundle 传值
bundle.putSerializable("ChooseTotalModel", model);
bundle.putString("category_id", category_id);
bundle.putInt("position", position);
q.setArguments(bundle);
return q;
}
这是获取值 的:
<span style="white-space:pre"> </span>chooseTotalModel = (ChooseTotalModel) getArguments().get("ChooseTotalModel");
category_id = getArguments().getString("category_id");
position = getArguments().getInt("position");
在activity里边 使用这个方法即可 QuestionFragment.getInstance( 参数);