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
Post a Comment