Why My Firebaserecyleradapter Not Working Properly?
I am trying to display all child 'name' located in My Database tree. I used this answer given by @Alex Mamo Unable to get All child data in Firebase Database using a Map? I want t
Solution 1:
displayName.setText(name);// display on the screen
You put this in a loop, where displayName
is only a singluar UI element. In other words, you'll always only see the very last name from the loop.
If you notice, your linked post there doesn't have any loop
You need to populate some ArrayList
List<String> names = newArrayList<>();
for (DataSnapshot dataSnapshot1 : dataSnapshot.getChildren()) {
String name = dataSnapshot1.child("name").getValue().toString();
names.add(name);
}
displayName.setText(names.toString());
Toast.makeText(context, names.toString(), Toast.LENGTH_LONG).show();
You can use that list in your RecyclerView, instead
Post a Comment for "Why My Firebaserecyleradapter Not Working Properly?"