How to retrieve the position in a ListView with Firebase results

后端 未结 2 404
梦谈多话
梦谈多话 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.

提交回复
热议问题