在Firebase中进行此更新之后,它已经引发了真正的问题n我被困在这件事
keyFire = this.getRef(position).getKey();
getKey()
方法不再使用它导致错误..
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) { }
});
}
};
答案 0 :(得分:0)
尝试一下:-
adapter.getRef(position).getKey();