hermt2
hermt2

Reputation: 874

Changing the bitmap image of an ImageView in android

So I have an ArrayList of Bitmap Images in my android app, and when I try to update the source of the image, nothing happens. The ImageView displays the first Bitmap Image without a problem in my app, but when I try to update the ImageView with a new Bitmap image, nothing changes, and I receive no errors and my app does not crash. Here is the code:

public void setFirstImage() {

    imagePreview.setImageBitmap(framesArray.get(0));

}

public void setLastImage() {
    Log.e("Image to display", "The image is " + framesArray.get(5));
    // Yes, this image does exist
    imagePreview.invalidate();
    imagePreview.setImageBitmap(framesArray.get(5));
}   

Upvotes: 1

Views: 995

Answers (1)

Cory Roy
Cory Roy

Reputation: 5609

Call invalidate() after changing the bitmap, not before.

Upvotes: 1

Related Questions