How to refer to adapter in the getview (of a listview) with this google syntax :
fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
return (convertView ?: layoutInflater.inflate(R.layout.my_layout, parent, false)).apply {
// … bind content from position to convertView …
//personal comment : "this" does not refer to adapter
}
}
Indeed, after the .apply, I have to call adapter in order to make an adapter.notifyDataSetChanged()
.
With a "classic syntax", adapter could be called thanks to "this", that is impossible with google syntax.
"Classic syntax"
fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
....
//"this" (refers to adapter)
return convertView
}
So is it possible to overriding the getview function to add variable in the signature ? Else, what is the solution of my problem ?