Hello Stackoverflow Community,
I can't seem to find the specific answer for my problem. I have a layout in android studio in which I can click a button to create a group. When clicked, I want to be able to store group names in the first ArrayList, and have the inner ArrayList filled with a list of members as they are added to the respective group.
So I will have an ArrayList of Group Names, and each of these names will have an ArrayList of members. I declared it as follows:
public static ArrayList<ArrayList<String>> gcinfo = new
ArrayList<ArrayList<String>>();
The following was taken from here:
How do I declare a 2D String arraylist?
List<List<String>> ls2d = new ArrayList<List<String>>();
List<String> x = new ArrayList<String>();
x.add("Hello");
x.add("world!");
ls2d.add(x);
for(List<String> ls : ls2d) {
System.out.println(Arrays.deepToString(ls.toArray()));
}
The code above makes sense and I assume I can change it the above code form List to ArrayList, but how do I set a 'String groupName' in ls2d when a new group is created?
Side Question: Given that I have not been able to figure this out yet, would I be able to use ArrayAdapter with the 2d ArrayList I want to create?