如何在populateviewholder中初始化FirebaseRecyclerAdapter

时间:2017-02-24 11:21:02

标签: android firebase firebase-realtime-database firebaseui

我试图从firebaserecycler适配器中的push()获取uid,但问题是我需要初始化firebaserecycleradapter,我该怎么办?

 protected void onStart() {
        super.onStart();


        FirebaseRecyclerAdapter<Users, UserViewHolder>firebaseRecyclerAdapter = new FirebaseRecyclerAdapter<Users, UserViewHolder>(
                Users.class,
                R.layout.account_row,
                UserViewHolder.class,
                mRef

        ) {
            @Override
            protected void populateViewHolder(UserViewHolder viewHolder, Users model, final int position) {

                viewHolder.setName(model.getName());

                viewHolder.mView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.w("asd", "You clicked on "+position);


                        DatabaseReference ref = firebaseRecyclerAdapter.getRef(position);

                        ref.getKey();

                        Log.w("asd", "This is the key "+ref);

                    }
                });
            }
        };

0 个答案:

没有答案