0

I am trying to display data from my firebase database in my listview using Firebase Listadapter. Below is my code

ListView list= findViewById(R.id.list_of_messages);
    FirebaseListAdapter<DRive>Adapter=new FirebaseListAdapter<DRive>(this,DRive.class,R.layout.messages,myRef) {
        @Override
        protected void populateView(View v, DRive model, int position) {
            ((TextView)v.findViewById(R.id.dropoff)).setText(model.getDropoffspot());
            ((TextView)v.findViewById(R.id.pickup)).setText(model.getPickupspot());
            ((TextView)v.findViewById(R.id.timed)).setText(model.getPickuptime());
            ((TextView)v.findViewById(R.id.points)).setText(model.getPassengers());



        }
    };
    list.setAdapter(Adapter);

}

I am getting the following error when trying to build:

error: constructor FirebaseListAdapter in class FirebaseListAdapter cannot be applied to given types;

required: FirebaseListOptions

found: MainActivity,Class,int,DatabaseReference

reason: actual and formal argument lists differ in length

where T is a type-variable:

T extends Object declared in class FirebaseListAdapter'

I got the idea of the code when Referring to a similar answered question here on stack overflow, How to populate a ListView using a FirebaseListAdapter? ,in this question however the individual used 3 closing brackets at the end when setting his 'prisview' Textview, when I tried that I received an error prompting me to remove the the third bracket. I am kindly asking for assistance

Community
  • 1
  • 1
Bwalya
  • 118
  • 11
  • You're calling the `FirebaseListAdapter` of an older version of FirebaseUI, but are including a newer version of the library. So the code won't compile. Follow the latest [documentation](https://github.com/firebase/FirebaseUI-Android/blob/master/database/README.md#using-firebaseui-to-populate-a-listview) to find the correct way to create your adapter, or https://stackoverflow.com/a/47691525, https://stackoverflow.com/a/47244091. If you tried the new constructor, but can't get it to work, show what you've tried for that. Right now your question is a duplicate of the ones I linked. – Frank van Puffelen Aug 06 '19 at 13:29
  • Thank you very much, I have looked at the links you sent, they have helped a lot. I apologize, I was not aware a similar question had been asked – Bwalya Aug 07 '19 at 11:38
  • I found the link by searching for the error message. Tagging the question correctly (in this case with `firebaseui` and `android`) also often helps for Stack Overflow to show links to relevant related questions. – Frank van Puffelen Aug 07 '19 at 14:13
  • That sounds like a different problem. Please undo the edits to this question, and open a new question for that. In that question include the **minimal** code needed to reproduce the problem (please read [how to create a minimal, complete, verifiable example](http://stackoverflow.com/help/mcve)), and don't forget to include the relevant JSON from your database (as text, no screenshot please). You can get this by clicking the "Export JSON" link in the overflow menu (⠇) on your [Firebase Database console](https://console.firebase.google.com/project/_/database/data). – Frank van Puffelen Aug 08 '19 at 12:58
  • Thank you, I will – Bwalya Aug 08 '19 at 13:50

0 Answers0