调试器显示程序进入循环但是专辑列表为空。 我不知道为什么?
d=FirebaseDatabase.getInstance().getReference().child(ALBUMES);
d.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
//clearing the previous artist list
albums.clear();
//iterating through all the nodes
for (DataSnapshot postSnapshot : dataSnapshot.getChildren()) {
//getting artist
Album album = postSnapshot.getValue(Album.class);
//adding artist to the list
albums.add(album);
}
//creating adapter
AlbumsLista albumAdapter = new AlbumsLista(getActivity(), albums);
//attaching adapter to the listview
listViewAlbums.setAdapter(albumAdapter);
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
Log.d(TAG, "albums:"+ albums.size());
}