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!
8/29/2018 8:25:18 PM
Paul Grasser5 Answers
New AnswersetImageResource is a method of ImageButton class then you have to call it on that object type... You did it?
Yes. val btn = imgbtn as ImageButton btn.setImageResource("@drawable/image") This gives me an error (I did import ImageButton
Hmmm... Dont knowing much kotlin system, i can only think that something in configuration is wrong... This happen with other android components?
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)
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message