https://i.stack.imgur.com/NOOWa.png
目前,我一直在使用这些类型的代码,并且正在使用模块类中的setter和getter方法。 现在我想从Users / uid / fullname获取全名
private DatabaseReference PostRef;
query sortPost=PostRef;
enter code hereFirebaseRecyclerOptions<Post> options=new FirebaseRecyclerOptions.Builder<Post>().setQuery(sortPost,Post.class).build();
@Override
protected void onBindViewHolder(@NonNull PostsViewHolder holder, int position, @NonNull final Post model)
{
final String PostKey=getRef(position).getKey();//get key by this line
PostRef.addValueEventListener(new ValueEventListener()
{
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot)
{
uidOfPostUser= dataSnapshot.child(PostKey).child("uid").getValue().toString();
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
holder.username.setText(model.getFullname());