I posted this question yesterday in the Java forum, but it's probably more appropriate in the Android section:
Java object added to ArrayList not showing
So I passed an ArrayList via a bundle however whenever I took a subject's Task ArrayList and added something the changes did not appear in the ArrayList.
To fix this instead of casting the Subject I passed the index in the ArrayList and did the subject assignment from the index.
So the Subject assignment was subject = subjectsList.get(index);
instead of:
Bundle bundle = getIntent().getExtras();
if (bundle != null) {
subject = (Subject) bundle.get("selected_subject");
subjectsList = (ArrayList<Subject>) bundle.get("subjects_list");
}
I'm still casting the ArrayList so I'm not sure why it does n't work when casting the subject. Can anyone explain this please. I think it may be do with the subject not being the same as the one in the ArrayList but I'm not sure.
Also surely the subject and ArrayList created in one activity and passed to another via a bundle are referring to the same object?