Question:
I’m trying to give context using “this” to a adapterCode is:
Type mismatch. Required: Activity
Answer:
Changeclass ShoeAdapter(private val context: Activity,...
to
class ShoeAdapter(private val context: Context,...
and
binding.listviewProfile.adapter = ShoeAdapter(this,shoeArrayList)
to
context?.run { binding.listviewProfile.adapter = ShoeAdapter(this,shoeArrayList) }
You could also keep the Activity but the adapter doesn’t need an Activity so it’s best to go with the more abstract
Context
.If you have better answer, please add a comment about this, thank you!