我試圖實施一個ListView
,並附上FirebaseListAdapter
。我需要顯示適配器內的字符串列表,所以我使用String
作爲通用字段。在火力地堡數據庫的結構是這樣的:在Kotlin中使用FirebaseListAdapter
我需要顯示users
節點所提供的密鑰(102127 ... 102133 ...等),所以我用這個代碼來創建適配器:
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
這是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
任何解決方案?