You must be using API level 26. This version has changed the signature of View.findViewById()
- see here https://developer.android.com/preview/api-overview.html#fvbi-signature
So in your case, where the result of findViewById
is ambiguous, you need to supply the type:
1/ Change
val listView = findViewById(R.id.list) as ListView
to
val listView = findViewById<ListView>(R.id.list)
2/ Change
this.label = row?.findViewById(R.id.label) as TextView
to
this.label = row?.findViewById<TextView>(R.id.label) as TextView
Note that in 2/ the cast is only required because row
is nullable. If label
was nullable too, or if you made row
not nullable, it wouldn't be required.