databaseReference.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (final DataSnapshot post : dataSnapshot.getChildren()) {
FirebaseRecyclerAdapter<GetModel, RecyclerViewAdapter.ViewHolder> mAdapter = new FirebaseRecyclerAdapter<GetModel, RecyclerViewAdapter.ViewHolder>
(GetModel.class, R.layout.rview, RecyclerViewAdapter.ViewHolder.class, query) {
@Override
protected void populateViewHolder(final RecyclerViewAdapter.ViewHolder viewHolder, final GetModel model, final int position) {
viewHolder.textview.setText(model.getName());
}
};
recyclerView.setAdapter(mAdapter);
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
此代码集
viewHolder.textview.setText(model.getName());
仅使用最后一个孩子的名字而不是每个孩子的名字。 如何解决这个问题?