onDataChange()中的Android Firebase Recycler视图UI

时间:2017-01-14 09:21:14

标签: android firebase firebase-realtime-database firebaseui

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());

仅使用最后一个孩子的名字而不是每个孩子的名字。 如何解决这个问题?

0 个答案:

没有答案