I have an arraylist for some kind of objects. These objects, have some attributes like strings and some integers. But also, an arraylist of another kind of objects.
I create the 2nd object first. And group them into an arraylist of this kind of objects. Then i check if this arraylist is empty. If its not, then i create the other object, and pass it the first arrayList. And put it inside another arraylist. So at the end, i have an arraylist of one kind of objects. And all of these objects, also have an arraylist (and a few other values, like some strings and integers) with other objects.
The problem is that at the end, when i try to acces the arraylist inside one of these objects, its empty.
Dont know if what im trying to do in imposible. Ive declared both arraylists as arraylists of objects. Perhaps i should declare them as an arraylist of arraylists?
Thanks in advance.
Edited:
Would be something like this:
class Obj1 {
String string;
int integer;
ArrayList objects2;
public Obj1(String string, int integer, ArrayList objects2) {
this.string = string;
this.integer = integer;
this.objects2 = objects2;
}
}
This would be the first object (its ArrayList objects2, but "<>" doesnt appear).
class Obj2 {
String string;
int integer;
public Obj2(String string, int integer2) {
this.string = string;
this.integer = integer;
}
}
Same as before with the "<>"s.
Then, with an asynctask, i start to search from a webpage. I create some Ob2. I can have from 0 to maybe, 15. So if i get some, put all of them into an ArrayList of Objs2. Then i create an Obj1 and pass it its attributes string and integer, and the ArrayList of Objs2. And after, put this Obj1 into ArrayList of Objs1.
At the end, i can have for example, 12 Ojs1 into an ArrayList. And each one of these Obj1, have an ArrayList of Objs2, with 1 to 15 Objs2. What i return from the asynctask is the ArrayList of Objs1.
Hope you understand what i mean. Also my english wont help. hehe
Thanks again.
Edited 2:
private class DownloadWork extends AsyncTask<URL, String, List<Obj1>>
{
ArrayList<Obj1>
objs1Downloaded = new ArrayList<Obj1>
();
ArrayList<Obj2>
objs2Downloaded = new ArrayList<Obj2>
();
//Some more stuff
protected List doInBackground(URL... params) {
for(...) {
//Do some stuff here ...
}
return objs1Downloaded;
}
That objs1Downloaded, as i said, would have 12 objs1 for example. And each obj1 could have an arraylist of objs2, with 1 to 15 obj2. Thats more or less the idea.
Thanks again and sorry for the edits and so.