I'm trying to implement a ListView
with a FirebaseListAdapter
attached on it. I need to display a list of strings inside the adapter, so I'm using String
as generic. The structure of the Firebase Database is this:
I need to display the keys available under the users
node (102127..., 102133..., etc.), so I'm using 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 the arguments supplied: public constructor FirebaseListAdapter(activity: Activity!, parser: ((DataSnapshot!) -> String!)!, @LayoutRes modelLayout: Int, query: Query!) defined in com.firebase.ui.database.FirebaseListAdapter public constructor FirebaseListAdapter(activity: Activity!, parser: SnapshotParser!, @LayoutRes modelLayout: Int, query: Query!) defined in com.firebase.ui.database.FirebaseListAdapter public constructor FirebaseListAdapter(activity: Activity!, modelClass: Class!, @LayoutRes modelLayout: Int, query: Query!) defined in com.firebase.ui.database.FirebaseListAdapter
Any solution?
Solved, the first argument of the FirebaseListAdaptwer
constructor (this
) wasn't an Activity
type.