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:
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?
source to share