我想从firebase获取所有颜色数据然后插入到arraylist,颜色数据结构如下图所示
这是我想插入Arraylist
的时候private void getDataDetailProduct() {
imageReference.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
if (dataSnapshot.exists()){
for (DataSnapshot childSbapshot : dataSnapshot.getChildren()){
String id = childSbapshot.getKey();
ArrayList<String>images = new ArrayList<>();
images.add(String.valueOf(childSbapshot.getChildren()));
}
initSlideImage();
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
答案 0 :(得分:1)
ArrayList<String>images = new ArrayList<>();
private void getDataDetailProduct() {
imageReference.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
if (dataSnapshot.exists()){
for (DataSnapshot childSbapshot : dataSnapshot.getChildren()){
String id = childSbapshot.getKey();
images.add(String.valueOf(childSbapshot.child("colors1").getValue()));
images.add(String.valueOf(childSbapshot.child("colors2").getValue()));
images.add(String.valueOf(childSbapshot.child("colors3").getValue()));
}
initSlideImage();
}}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}