[英]getRef(position).getKey() in RecyclerView.Adapter
[英]does not recognize me getRef (position) is onBindViewHolder working with Firebase
getRef()
不接受来自文档的参数:
public DatabaseReference getRef ()
用于获取对该快照的源位置的引用。
返回值:
与该快照来自的位置相对应的DatabaseReference
你可以这样做:
使用名为productList
final String product_key=productList.get(position).getKey();
此处提供更多信息: https : //firebase.google.com/docs/reference/android/com/google/firebase/database/DataSnapshot.html#getRef()
在onBindViewHolder
方法内部,您可以使用以下代码行获取密钥:
String product_key = getItem(position);
getRef()用于获取对快照源位置的引用。 因此,您只能在快照对象上使用此方法。 它返回一个DatabaseReference
并且不带参数。 下面是一个例子:
DatabaseReference ref = snapshot.child("users").getRef();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.