In some cases you are able to use property access syntax to reference Java getters/setters, in some cases you aren’t. What defines this behaviour?
val tv = TextView(this)
tv.setText("") // WEAK WARNING: Use of setter method instead of property access syntax
tv.text = "" // OK
val iv = ImageView(this)
iv.setImageResource(R.drawable.ic_launcher_background) // no weak warning, meant to be used that way
iv.imageResource = R.drawable.ic_launcher_background // ERROR: Unresolved reference: imageResource
>Solution :
From the Kotlin documentation:
Note that, if the Java class only has a setter, it isn’t visible as a property in Kotlin because Kotlin doesn’t support set-only properties.
ImageView has a setImageResource but no getImageResource, so it falls into the category mentioned above.
