I\'m trying to replicate the following ListView in my Android app using Kotlin: https://github.com/bidrohi/KotlinListView.
Unfortunately I\'m getting an error I\'m u
You must be using API level 26 (or above). This version has changed the signature of View.findViewById()
- see here https://developer.android.com/about/versions/oreo/android-8.0-changes#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
2/ Change
this.label = row?.findViewById(R.id.label) as TextView
to
this.label = row?.findViewById
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.