从Firebase Firestore Android检索子集合文档

时间:2019-10-17 08:51:23

标签: android firebase android-recyclerview google-cloud-firestore

我想从Firebase firestore android检索子集合文档,并在回收器视图中显示它,但是在回收器视图中什么都没有显示,我认为数据检索存在问题

 var myarray=ArrayList<User>()
   rv=findViewById(R.id.idrecycler) as? RecyclerView
    notebookRef.addSnapshotListener { querySnapshot, firebaseFirestoreException ->
           for(uid in querySnapshot!!.documentChanges){
               uid.document.reference.collection("ProfileData")
                   .addSnapshotListener { querySnapshot2, firebaseFirestoreException ->
                   for(da in querySnapshot2!!){
                  val note = da.toObject(Note::class.java)
                       var title = note.title
                  var description = note.notes
                           var note2 = da.toObject(Note2::class.java)
                           var username = note2!!.username
                           myarray.add(User(username!!,str.child(currentuser),title!!,description!!))
                       }
              }
  }}

User.class

data class User(
    var username:String,
    var userphoto: StorageReference,
    var title:String,
    var notes:String
)

uid是UserUID da是一些笔记的ID

数据库快照:

enter image description here

0 个答案:

没有答案