I want to pass an Arraylist (SearchModl is a class) from one fragment to another. i am using Bundle to do this.But when ever I get the bundle in other fragment,i am getting null value
SearchModel
public class SearchModel implements Serializable {
private String code,category, minExp, maxExp, postedOn, counts, applied, position, desc, type, hour, status, expiryDate, address, gender, religion, summary, requestId, requestorId;
public SearchModel(String code,String category, String minExp, String maxExp, String postedOn, String counts, String applied, String position, String desc, String type, String hour, String status, String expiryDate, String address, String gender, String religion, String summary, String requestId, String requestorId) {
this.code=code;
this.category = category;
this.minExp = minExp;
this.maxExp = maxExp;
this.postedOn = postedOn;
this.counts = counts;
this.applied = applied;
this.position = position;
this.desc = desc;
this.type = type;
this.hour = hour;
this.status = status;
this.expiryDate = expiryDate;
this.address = address;
this.gender = gender;
this.religion = religion;
this.summary=summary;
this.requestId = requestId;
this.requestorId = requestorId;
}
Fragment A
for (int i = 0; i < tableArray.length(); i++) {
JSONObject table = tableArray.getJSONObject(i);
data = new SearchModel(table.getString("Job_Code"), table.getString("Job_Category"), table.getString("Min_Exp"), table.getString("Max_Exp"), table.getString("Posted_On"), table.getString("Candidate_Counts"), table.getString("Applications"), table.getString("No_Of_Pos"), table.getString("Job_Desc"), table.getString("Job_Type"), table.getString("Job_Hours"), table.getString("Job_Status"), table.getString("Job_Exp_Date"), table.getString("Address"), table.getString("Gender_Name"), table.getString("Religion_Name"), table.getString("Exp_Summary"), table.getString("IJob_Request_ID"), table.getString("Requestor_Name"));
values.add(data);
}
// getArrayList.getArray(values);
bundle.putSerializable("array", (java.io.Serializable) values);
}
} catch (JSONException e1) {
e1.printStackTrace();
}
}
CommonFunctions.showProgress(getActivity(), "Please Wait...", false);
fragmentTransaction = getFragmentManager().beginTransaction();
SearchJobList searchJobList = new SearchJobList();
searchJobList.setArguments(bundle);
fragmentTransaction.replace(R.id.header_container, searchJobList, "searchJob").commit();
}
});
Second Fragment
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
data = new ArrayList<SearchModel>();
Bundle bundle = getArguments();
data = (List<SearchModel>) bundle.getSerializable("array");
getArrayList = new GetArrayList() {
@Override
public void getArray(List<SearchModel> listValues) {
data = listValues;
jobAdapter = new SearchJobAdapter(getActivity(), data);
setListAdapter(jobAdapter);
}
};
}