先上接收到的对象效果(Activity中的)
1.传递
.withSerializable("dateBean",dateBean)
2.对象(这里只是示例,所以没有把全部的属性放出来,用…………代替了。我传递的是DataBean,所以DataBean进行Serializable)
public class LeaveListResponse {
…………………………………………
private List<DataBean> data;
public List<DataBean> getData() {
return data;
}
public void setData(List<DataBean> data) {
this.data = data;
}
public static class DataBean implements Serializable {
………………………………
private String LeaveId;
public String getLeaveId() {
return LeaveId;
}
public void setLeaveId(String LeaveId) {
this.LeaveId = LeaveId;
}
}
}
3.activity中接收(注:此处的dateBean跟前面传递的"dateBean"一致)
Intent intent = getIntent();
LeaveListResponse.DataBean dateBean = (LeaveListResponse.DataBean)intent.getSerializableExtra("dateBean");
4.fragment接收
4.1 在fragment对应的主activity中,在切换到BFragment中添加如下代码(case 1是代表着切换到BFragment):
Bundle bundle = new Bundle();
bundle.putSerializable("dateBean", getIntent().getSerializableExtra("dateBean"));
BFragment.setArguments(bundle);
4.2 fragment接收
LeaveListResponse.DataBean dateBean= (LeaveListResponse.DataBean) getArguments().getSerializable("dateBean");