This is my database. For now only have 2 users but there will be more in the future so I wanted to add row according to the number of users I have in my database. I am able to retrieve the data from fire store but I cant think of a way to add row based on the quantity of my documents.
AdminFragment
final TableLayout table1 = v.findViewById(R.id.table);
final FirebaseFirestore reference = FirebaseFirestore.getInstance();
reference.collection("users").get().addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if(task.isSuccessful()){
List<String> list = new ArrayList<>();
for (QueryDocumentSnapshot document : task.getResult()) {
TableRow tr = new TableRow(getActivity());
tr.setLayoutParams(new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT));
TextView tv = new TextView(getActivity());
tv.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT));
TextView tv2 = new TextView(getActivity());
tv.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT));
String email = document.getString("Email");
String fname = document.getString("FName");
tv.setText(email);
tv2.setText(fname);
}
}
}