Reputation: 359
I try to show a detail of the list but getref () does not recognize me,I want to get the key to go to another activity, help please, I'm new.
this is a class is not an activity
Upvotes: 1
Views: 1298
Reputation: 138944
Inside onBindViewHolder
method you can get the key using the following line of code:
String product_key = getItem(position);
getRef() is used to obtain a reference to the source location for the snapshot. So you can only use this method on a snapshot object. It returns a DatabaseReference
and takes no argument. Below an example:
DatabaseReference ref = snapshot.child("users").getRef();
Upvotes: 1
Reputation: 80924
getRef()
in firebase does not accept parameters, from the documentation:
public DatabaseReference getRef ()
Used to obtain a reference to the source location for this snapshot.
Returns:
A DatabaseReference corresponding to the location that this snapshot came from
You can do this:
Using an arrayList, called productList
final String product_key=productList.get(position).getKey();
more info here: https://firebase.google.com/docs/reference/android/com/google/firebase/database/DataSnapshot.html#getRef()
Upvotes: 1