How can I retrieve data from Firebase to my adapter

前端 未结 3 617
南旧
南旧 2020-11-21 06:29

My structure

So I have an app in which users upload posts in my adapter. I can retrieve the post description and the post picture, but when I try to retriev

3条回答
  •  无人及你
    2020-11-21 06:58

    The code below goes inside onBindviewhoder() under this line:

        String user_id = . . .. . . . 
    

    I guess its the way you refer to your data and the way you attach the listener. Try to initialize the database ref like this:

      DatabaseReference firebaseDatabase= FirebaseDatabase.getInstance().getReference().child("Users").child(user_id);
    

    and now try to listen like this:

       firebaseDatabase.addValueEventListener(new ValueEvent....{
    
        onDataChange(.....){
    
         //your same code
    
        }
    
    
    
       })
    

提交回复
热议问题