Skip to content
Advertisement

How to reference an ImageView from inside Java code in Android?

I have this xml-file:

JavaScript

I’m calling my TextView in my java code like this:

JavaScript

Is there any way to do the same for an ImageView?

Advertisement

Answer

Ya sure.. you can create an object as like TextView you did above,and create a folder named drawable under res folder and place the image u need,and set image view image by calling its id from drawable

For ex:

JavaScript
  • without the extension of image.
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement