Firebase RecyclerView适配器 - 加入查询

时间:2017-06-25 04:59:20

标签: android firebase firebase-realtime-database android-recyclerview

我正在尝试从一个表(homeaccount)获取UserID,并使用用户ID从另一个表(userinfo)获取用户的信息。我尝试通过以下方式实现。但是,它会将卡片视图叠加在另一个上面。

databaseReference.child("homeaccount/"+globalSharedPrefs.getUserDetail("currenthome")+"/Users")
.addChildEventListener(new ChildEventListener() {
    @Override
    public void onChildAdded(DataSnapshot dataSnapshot, String s) {
        String str_iteration_uid = dataSnapshot.getKey();
        userQuery = databaseReference.child("userinfo").orderByChild("uid").equalTo(str_iteration_uid);
        firebaseRecyclerAdapter = new FirebaseRecyclerAdapter<HomeUsers, HomeUsersViewHolder>(
                HomeUsers.class,
                R.layout.cardview_manage_user,
                HomeUsersViewHolder.class,
                userQuery
        ){
            @Override
            protected void populateViewHolder(final HomeUsersViewHolder viewHolder, final HomeUsers model, int position) {
                //viewHolder.setFirstName(model.getFirstName());
                //viewHolder.setProfilePicture(model.getProfilePicture());
            }
        };
        recyclerView.setAdapter(firebaseRecyclerAdapter);
    }

    @Override
    public void onChildChanged(DataSnapshot dataSnapshot, String s) {

    }

    @Override
    public void onChildRemoved(DataSnapshot dataSnapshot) {

    }

    @Override
    public void onChildMoved(DataSnapshot dataSnapshot, String s) {

    }

    @Override
    public void onCancelled(DatabaseError databaseError) {

    }
});

0 个答案:

没有答案