reader reader - 1 year ago 63
Java Question

how to change the name of array in android script

i have arrays say for ex

int img1[] = {R.drawable.a1,R.drawable.a2,....}
int img2[] = {R.drawable.b1,R.drawable.b2,....}
int img3[] = {R.drawable.c1,R.drawable.c2,....}

I want to define a varibale for ex imgn
where when on some condition it has to select the different array
imgn= img1 or imgn= img2 etc

if (rnd.nextInt(4) == 1) (

where rnd is defined as Random


Answer Source

You can use HashMap

HashMap<String,int[]> arraynames = new HashMap<String,int[]>();
arraynames.put("img1", new int[]{R.drawable.a1,R.drawable.a2,....});


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download