android - How to set images id dynamically in integer array -


here code, have 100 images , want create dynamic using loop it's not working.

   int[] imgids = {r.drawable.img1, r.drawable.img2, r.drawable.img3}; 

try using getresources().getidentifier create array of drawable id's if drawables name img1,img2,img3,..

int[] imgids = new int [100]; int imagecount=1; for(int i=0;i<100;i++){ imgids[i]=getresources().getidentifier("img"+imagecount,                                            "drawable", getpackagename()); imagecount++; } 

Comments

Popular posts from this blog

hibernate - How to load global settings frequently used in application in Java -

python 3.x - Mapping specific letters onto a list of words -

objective c - Ownership modifiers with manual reference counting -