我试图从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);
}
});
}
};