Doing this for an Android project; having issues creating An ArrayList out of what was formerly an Array of objects.
Here is what code WAS:
MyReviewObject[] co = new MyReviewObject[reviews.size()];
int index = 0;
for (@SuppressWarnings("unused")
String i : reviews) {
co[index] = new MyReviewObject(datelist.get(index),
reviews.get(index), items.get(index),
cats.get(index));
index++;
}
adapter = new MyReviewAdapter(getActivity(), co);
setListAdapter(adapter);
Here is what I have now:
ArrayList<MyReviewObject> co = new ArrayList<MyReviewObject>();
for (String i : reviews) {
co = new ArrayList<MyReviewObject>(datelist.add(i),reviews.add(i), items.add(i), cats.add(i));
}
adapter = new MyReviewAdapter(getActivity(), co);
setListAdapter(adapter);
The statement in the for loop I am having hard time converting to make work? I know I am declaring the ArrayList twice and one should go.
EDIT:
here is Object:
public class MyReviewObject {
public String comment;
public String date;
public String items;
public String cat;
public MyReviewObject(String s1, String s2, String s3, String s4) {
this.date = s1;
this.comment = s2;
this.items = s3;
this.cat = s4;
}
}