我正在尝试通过代码
从firebase检索图像DatabaseReference reference = FirebaseDatabase.getInstance().getReference();
Query query = reference
.child(mContext.getString(R.string.dbname_user_account_settings))
.orderByChild(mContext.getString(R.string.field_user_id))
.equalTo(getItem(position).getUser_id());
query.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for ( DataSnapshot singleSnapshot : dataSnapshot.getChildren()){
ImageLoader imageLoader = ImageLoader.getInstance();
imageLoader.displayImage(
singleSnapshot.getValue(UserAccountSettings.class).`getProfile_photo()`,
holder.profileImage);
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
Log.d(TAG, "onCancelled: query cancelled.");
}
});
UserAccountSettings类中的位置
public String getProfile_photo() {
return profile_photo;
}
public void setProfile_photo(String profile_photo) {
this.profile_photo = profile_photo;
}
现在它没有检索任何图像,我试着写一个toast信息来检查是否正在调用onDataChange
,但仍然没有出现任何toast。
请给我一个正确检索它的想法。