How to retrieve the position in a ListView with Firebase results

后端 未结 2 403
梦谈多话
梦谈多话 2021-01-25 08:51

I\'m not using FirebaseAdapter or any Firebase-UI dependency, I have made this completly native for now, but I\'m getting a problem at

相关标签:
2条回答
  • 2021-01-25 09:15

    To solve this, you need to change the following line of code:

    mRootDatabase = getAdapter(mContext).getItem(position);
    

    to

    mRootDatabase = adapter.getRef(position);
    

    In which adapter variable is the actual adapter that you are using to display the data.

    Edit:

    You cannot use getRef() method, unless you are using Firebase-UI library. You cannot get the DatabaseReference object from the ArrayAdapter object. None of the methods inside this class return a DatabaseReference object. The only way in which you can achieve this is to use Firebase-UI library.

    0 讨论(0)
  • 2021-01-25 09:20

    It looks like you're trying to assign a Pojo to a Database Reference, instead you would need to assign it to the actual pojo and reference it that way Something like this

    UserPojo User = adapter.getItem(position);
    
    0 讨论(0)
提交回复
热议问题