set image programmatically android 1

set image programmatically android

mImageView.setBackgroundResource(R.drawable.ic_thumbs_up);

Here is what the above code is Doing:
1. We’re creating a new instance of the ImageView class.
2. We’re setting the image resource to the R.drawable.ic_thumbs_up resource.
3. We’re setting the background resource to the R.drawable.ic_thumbs_up resource.

The difference between the two is that the image resource is the image that will be displayed in the ImageView, and the background resource is the image that will be displayed behind the ImageView.

Similar Posts