无法在 FirebaseUI 中的 FirebaseRecyclerAdapter 中使用" this.getRef(position).getKey(); "



在Firebase中进行此更新后,它引起了真正的问题n我被困在这件事上

keyFire = this.getRef(position).getKey();

getKey()方法不再使用它 n 导致错误。

Cannot resolve method 'getKey()'

代码如下:

FirebaseRecyclerAdapter<Boolean, FriendsViewHolder> adapter = new FirebaseRecyclerAdapter<Boolean, FriendsViewHolder>(
                Boolean.class,  R.layout.chat_view_list, FriendsViewHolder.class, friendsRef){
            protected void populateViewHolder(final FriendsViewHolder viewHolder, Boolean model, final int position) {
       --> -->       keyFire = this.getRef(position).getKey();
                keyhold=keyFire;
                final DatabaseReference  mFirebaseRef= FirebaseDatabase.getInstance().getReferenceFromUrl(constants.FIREBASE_URL+"rootssahaj/authGplus");
                mFirebaseRef.child(keyFire).addListenerForSingleValueEvent(new ValueEventListener() {

                    public void onDataChange(DataSnapshot dataSnapshot) {
                                String name = dataSnapshot.child("userNAME").getValue(String.class);
                                String picurl = dataSnapshot.child("picurl").getValue(String.class);
                                String status = dataSnapshot.child("status").getValue(String.class);
                        Log.e("SahajLOG", "DATASNApshot  " +dataSnapshot+ "  name " +name);
                        if(name==null){
                            dialogLayout.setVisibility(View.VISIBLE);
                        }
                        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Mcontext);
                        prefs.edit().putString("OtherUserNames"+position,name).commit();
                        Log.e("SahajLOG", "POSITION   " +position+"  " +dataSnapshot.getKey());
                        prefs.edit().putString("OtherEmail"+position , dataSnapshot.getKey()).commit();
                        prefs.edit().putString("UserEmail",EmailPref).commit();
                        viewHolder.mName.setText(name);
                                viewHolder.mStatus.setText(status);
                                Picasso.with(context).load(picurl).transform(new CircleTransform()).into(viewHolder.mImageProfile);
                    }
                    public void onCancelled(DatabaseError firebaseError) { }
                });
            }
        };

试试这个:-

adapter.getRef(position).getKey();

相关内容

  • 没有找到相关文章

最新更新