Make a vector with the images:
int[] imagensIds = {
R.drawable.image1,
R.drawable.image2,
R.drawable.image3
};
//E um int para saber qual posição
int i = 0;
Your image loads the first with the position of "i":
img.setImageResource(imagensIds[i]);
And then clicking the button:
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
i++;
img.setImageResource(imagensIds[i]);
}
});
If it were to go back you would use "i -"
But here it is up to you to do an if to check if it is already in the last image so it does not reach for example i = 3
and there is no index 3 in the image vector