连接两个用户ID Firebase数据库

时间:2018-11-16 15:21:47

标签: android

我正在制作包含Firebase Pet的Cardview Feed 具有这样的布局

Pet table

另一个表是用户

User table

我想填充cardview并将UID从Pets转换为用户名。

在这里输入我的代码

code

1 个答案:

答案 0 :(得分:0)

 @Override
public void onStart() {
    super.onStart();
FirebaseRecyclerAdapter<Model, ViewHolder> firebaseRecyclerAdapter =
        new FirebaseRecyclerAdapter<Model, ViewHolder>(Model.class,R.layout.row,ViewHolder.class,mref)
        {

            @Override
            protected void populateViewHolder(ViewHolder viewHolder, Model model, int position) {
                String userid = model.getUserid().toString();


                viewHolder.setDetails(getActivity().getApplicationContext(),model.getPetname(),"Reason:" + model.getReason(),model.getPetpicture(),"Breed:" + model.getBreed(),
                       "Age:  " + model.getAge(),"Size: " +  model.getPetsize() +"yrs old","Color:" + model.getPetcolor(),"",model.datepost);
            }
        };

    recyclerView.setAdapter(firebaseRecyclerAdapter);
}