【发布时间】:2019-12-25 00:32:03
【问题描述】:
我在fragmentA 中显示我的目标列表,当我点击其中一个时,我将此目标的 guid 传递给fragmentB
之后,我尝试在fragmentB 中为这个guid 显示这个目标的数据:
private fun fetchTarget(guid: String) {
val uid = firebaseUser!!.uid
// Attach a listener to read the data at the target id
databaseReference?.child("targets")?.child("users")
?.child(uid)?.child("targets")?.child(guid)?.addValueEventListener(object : ValueEventListener {
override fun onDataChange(dataSnapshot: DataSnapshot) {
val data = dataSnapshot.value as? HashMap<String, String>?
val name = data?.get("name") ?: ""
val description = data?.get("description") ?: ""
if (name.isEmpty()) Log.d("some", "nameIsEmpty")
else updateViewsContent(name = name, description = description)
}
override fun onCancelled(databaseError: DatabaseError) {
Log.d("some", databaseError.message)
}
})
}
这里我得到了指导:-LmfEVnwgqCUqt7beHDg
在我的控制台中,我有下一个结构:
不幸的是,我无法显示目标的数据,尽管就像我安装的所有链一样
问:如何下载-LmfEVnx-y7c3oh8_U9F?
【问题讨论】:
标签: android firebase firebase-realtime-database kotlin