2017-09-25 58 views
0

嗨,在我的Firebase回收站適配器中,在我的第四個參數中,我需要數據庫引用,但是我想引用一個孩子,並從該孩子的UID中引用另一個孩子。就像下面的截圖一樣:我試圖從「Chatmessages」中引用密鑰,然後用它來引用「用戶」中的密鑰。但是,我如何在我的Recycler Adapter中執行此操作?Firebase Recycler Adapter

DB struc

public void loadUserList() { 
    FirebaseRecyclerAdapter<User, UserViewHolder> firebaseRecyclerAdapter = new FirebaseRecyclerAdapter<User, UserViewHolder>(
      User.class, 
      R.layout.userlist_layout, 
      UserViewHolder.class, 

      users // ref 
    ) 

回答

0

您應該使用FirebaseIndexRecyclerAdapter從火力地堡的UI:

public void loadUserList() { 
    String chatMessageId = "5kA...LT2"; // Get or pass this key somehow 
    DatabaseReference userKeyRef = rootRef.child("Chatmessages").child(chatMessageId); 
    DatabaseReference userRef = rootRef.child("Users"); 
    FirebaseIndexRecyclerAdapter<User, UserViewHolder> firebaseRecyclerAdapter = new FirebaseIndexRecyclerAdapter<User, UserViewHolder>(
      User.class, 
      R.layout.userlist_layout, 
      UserViewHolder.class, 
      userKeyRef, 
      userRef 
    ) 
+0

感謝youuuu ..! –

相關問題