int i = 1;
String IMG = "pic";
IMG = IMG + Integer.toString(i);
i = i + 1;
imageview1.setImageResource(R.drawable.IMG);
R.drawable.IMG where IMG is a variable.
This is wrong. What would the right way? I want to change a imageview from pic1 to picN.
int[] images = new int[]{R.drawable.pic1, R.drawable.pic2, R.drawable.pic3};
This is better, but How can I insert a vector element into a imageview?
Sorry for my bad english level 🙂
The identifiers that identify the resources in your app are not a series of sequential numbers. Create an array of the images you’ve added, e.g.
and increment the index in that instead?