Q:

How to change image of a button on click?

I have an array of bitmaps ArrayList<Bitmap> images = new ArrayList<>(3) and need to change the image of a ImageButton in every click, first  images(0) then, after I click image(1) and finally image(2). 
For this I am using myImageButton.setImageBitmap(images.get(0)) for the first image, how do I change to the next and then to the third?

A:

You should use
int currentPos = 0;
onclick(){
 currentPos = (currentPos+1)%(images.size()-1)
 myImageButton.setImageBitmap(images.get(currentPos))
}

