Hy guys, I need to retrieve an arraylist saved in firestore which contains a list of partecipants that I have to put in a spinner. I can't figure out how to get the entire arraylist. That's my code:
public ArrayList<String> getPartecipantsList(){
String email = getEmail();
String groupTitle = getTitleBar();
DocumentReference docRef = db.collection("users").document(email).collection("Group").document(groupTitle);
docRef.get()
.addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
@Override
public void onComplete(@NonNull Task<DocumentSnapshot> task) {
DocumentSnapshot document = task.getResult();
//Extracting participants ArrayList from each document
for(Object item : task.getResult().getData().values()) {
partecipantsArrayList.add(item.toString());
Log.v("vettore", String.valueOf(partecipantsArrayList));
}
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
}
});
return partecipantsArrayList;
}
Then for the spinner:
public void load_spinner(){
partecipantsArrayList = getPartecipantsList();
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, partecipantsArrayList);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
}
That's a picture of the database
The problem is that in this way, I get all the field in the document..how can i get only the partecipant field?