// Creating an ImageView ImageView imageView = new ImageView(this); // Setting the unique identifier of the ImageView imageView.setId(R.id.my_image_view);
// Retrieving an ImageView by its unique identifier ImageView imageView = findViewById(R.id.my_image_view); // Display an image in the ImageView imageView.setImageResource(R.drawable.my_image);In this example, we are retrieving an ImageView that has previously been assigned the unique identifier "my_image_view" using the findViewById method. We then use the setImageResource method to display an image in the ImageView. Once again, the R class in the package library contains the resource identifiers for the images.