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

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

javascript - jquery or ashx not working -

inno setup - TLabel or TNewStaticText - change .Font.Style on Focus like Cursor changes with .Cursor -