Using what is perhaps obvious, is actually incorrect, since pairing R.id.imageCas+""+i
will result in an incorrect value, even a value that might not be integer by length.
int valorId = Integer.parseInt(R.id.imageCas+""+i);
The ids generated by each resource found in your project are of the integer type and are written inside the file R.java
, as an example for the layouts you have:
public static final class layout {
public static final int activity_main=0x7f04001e;
public static final int activity_alert=0x7f04001f;
public static final int activity_configuration_alerts=0x7f040020;
public static final int activity_contact=0x7f040021;
public static final int activity_detail=0x7f040022;
public static final int activity_email=0x7f040024;
public static final int activity_gallery=0x7f040026;
public static final int activity_main_bubble=0x7f040029;
}
but these id's can change for that reason as a suggestion is to store the name of the layout or resource, within an array of integer values, for example:
private static final int[] mylayouts = new int[]{R.id.activity_main, R.id.activity_alert, R.id.activity_configuration_alerts, R.id.activity_contact, R.id.activity_detail, R.id.activity_email, R.id.activity_gallery, R.id.activity_main_bubble};