我使用过FirbaseRecyclerAdapter但是我很难找到跟随孩子的价值是我用过的代码
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
recyclerView = findViewById(R.id.recyclerView);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
Toast.makeText(this, "Created", Toast.LENGTH_SHORT).show();
listitems = new ArrayList<>();
databaseReference = FirebaseDatabase.getInstance().getReference().child("content");
}
@Override
protected void onStart() {
super.onStart();
FirebaseRecyclerAdapter<Listitem ,BlogViewHolder> firebaseRecyclerAdapter = new FirebaseRecyclerAdapter<Listitem, BlogViewHolder>(
Listitem.class,R.layout.list_item,BlogViewHolder.class,databaseReference
) {
@Override
protected void populateViewHolder(BlogViewHolder viewHolder, Listitem model, int position) {
viewHolder.sethead(model.getHead());
viewHolder.setdesc(model.getDesc());
}
};
recyclerView.setAdapter(firebaseRecyclerAdapter);
}
答案 0 :(得分:0)
-L7n...Udk3D
下有一个额外的duck
密钥,这很可能是因为Listitem
模型类无法查找head
和{ {1}}属性。要修复它,请删除额外的description
密钥。