我想将所有数据显示到Recycleview中,但只有第一个图像加载不是 显示recycleviewList任何人都有这个想法。
mFirebaseInstance = FirebaseDatabase.getInstance();
// get reference to 'users' node
mFirebaseDatabase = mFirebaseInstance.getReference("items");
mFirebaseDatabase.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
String getImage= (String) dataSnapshot.getValue();
String ConvertImage;
ConvertImage = getImage.replaceAll("\\[",
"").replaceAll("\\]","");
String[] items = ConvertImage.split(",");
List<String> list = Arrays.asList(items);
Log.e("list",list.toString());
for (String item : list) {
arraylist.add(item);
setImg(arraylist);
}
}
@Override
public void onCancelled(DatabaseError error) {
// Failed to read value
}
});
答案 0 :(得分:2)
要获取所有这些链接,请使用以下代码:
DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference();
DatabaseReference itemsRef = rootRef.child("items");
ValueEventListener eventListener = new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for(DataSnapshot ds : dataSnapshot.getChildren()) {
String link = ds.getValue(String.class);
Log.d("TAG", link);
}
}
@Override
public void onCancelled(DatabaseError databaseError) {}
};
itemsRef.addListenerForSingleValueEvent(eventListener);
输出将包含来自item
节点的所有链接。