0
Kotlin: Set Image SRC
Hello. So I am trying to set the source of an ImageButton (Android Studio) using Kotlin. I looked it up, and found I should just use setImageResource(image) However, I get the error: Unresolved Reference: setImageResource How can I fix it? Thanks!
5 Answers
+ 4
setImageResource is a method of ImageButton class then you have to call it on that object type... You did it?
+ 1
Yes.
val btn = imgbtn as ImageButton
btn.setImageResource("@drawable/image")
This gives me an error (I did import ImageButton
0
Hmmm... Dont knowing much kotlin system, i can only think that something in configuration is wrong... This happen with other android components?
0
KrOW no.
0
Paul Grasser Its very hard figure out what is the problem.... I think that something go bad with environment (android studio or gradle)... Try to clear cache of AS and of Gradle and rebuild all (search on google)