android - How to optimize this references statements findViewById() -
i have activity 80 imageview, have add references in java file & doing this. there way simplyfy code. please me.
iv[0]=(imageview)findviewbyid(r.id.iv0); iv[1]=(imageview)findviewbyid(r.id.iv1); iv[2]=(imageview)findviewbyid(r.id.iv2); iv[3]=(imageview)findviewbyid(r.id.iv3); iv[4]=(imageview)findviewbyid(r.id.iv4); iv[5]=(imageview)findviewbyid(r.id.iv5); ....... iv[79]=(imageview)findviewbyid(r.id.iv79);
a simple for
loop appropriate in case:
for (int = 0 ; < iv.length ; ++i) { int resourceid = this.getresources().getidentifier("iv" + i, "id", this.getpackagename()); iv[i] = (imageview) findviewbyid(resourceid); }
but optimise code. use recyclerview
, show images in adapter. way surely outofmemoryerror
's.
Comments
Post a Comment