I've tried hundreds of ways to resolve this reference problem:
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
setSupportActionBar(toolbar)
val dm = DataManager()
val adapterCourses = ArrayAdapter<CourseInfo>(context: this,
android.R.layout)
but in ArrayAdapter<CourseInfo>(context: this, android.R.layout) I get unresolved reference: context and I have no idea why.
Android Studio version: 3.3.2 Kotlin version: 1.3.21
Could anyone help me?
I had a similar error message because I didn't import the Context.
If you haven't explicitly imported Context, try adding this to your import list near the start of your Activity file:
import android.content.Context
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With