Using FirebaseListAdapter in Kotlin

I am trying to implement ListView

with attached to it FirebaseListAdapter

. I need to display a list of strings inside an adapter, so I use String

as generic. The Firebase database structure is as follows:

enter image description here

I need to display the keys available under users

node (102127 ..., 102133 ... etc), so I use this code to create the adapter:

val ref = db.getReference(MATCHES_REF).child(match).child(USERS_REF)
val adapter = object : FirebaseListAdapter<String>(this, String::class.java, R.layout.cell_friends, ref) {
    override fun populateView(view: View, s: String, i: Int) {
        val text = view.findViewById(R.id.text_view) as TextView
        text.text = s
    }
}
listView?.adapter = adapter

      

This is the error shown in Android Studio:

Error: (50, 32) None of the following functions can be called with arguments: public constructor FirebaseListAdapter (action: Activity !, parser: ((DataSnapshot!) β†’ String!) !, @LayoutRes modelLayout: Int, query: Query!), Defined in the public constructor com.firebase.ui.database.FirebaseListAdapter FirebaseListAdapter (Activity: Activity !, parser: SnapshotParser !, @LayoutRes modelLayout: Int, query: Query!) Is defined in com.firebase.ui.database. FirebaseListAdapter public constructor of FirebaseListAdapter (Activity: Activity !, modelClass: Class !, @LayoutRes modelLayout: Int, query: Query!) Defined in com.firebase.ui.database.FirebaseListAdapter

Any solution?

+3


source to share


1 answer


Solved, the first argument to the constructor FirebaseListAdaptwer

( this

) was not a type Activity

.



+2


source







All Articles