What you can do is loop over all the children of your database and add them to an ArrayList
and then use an array adapter to display the list.
What I am saying, looks something like this in code:
rootRef.child("Rooms").addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
for (DataSnapshot ds : dataSnapshot.getChildren()) {
array.add(ds.child("Users").child("UserID").getValue(String.class));
}
ArrayAdapter adapter = new ArrayAdapter(YourActivity.this, android.R.layout.simple_list_item_1, array);
listView.setAdapter(adapter);
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
// Do something for errors too
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.