我如何通过一个变量访问的Adroid绘制? 例 我可绘:[logo1.png logo2.png ... logoN.png]。 有没有办法,所以我能做到这一点?
How can i access an Adroid drawable by a variable? Example I have drawables :[ logo1.png logo2.png ... logoN.png]; Is there a way so i can do that?
String logopicker="1";
logo.setImageResource(R.drawable.**logo+logopicker**);
嗯,我知道这code永远不会运行,但你得到了什么,我想做的事情的想法。 谢谢
Well i know this code will never run but you get the idea of what i want to do. Thank you
这code上对我的成功(我已经用我的应用程序的一个), 你可以试试这个:
This code is running for me successful (I have already used in my one of the application), You can Try this:
cnt=1;
String icon="logo" + cnt;
int resID = getResources().getIdentifier(icon, "drawable", getPackageName());
logo.setImageResource(resID);
cnt++; // this require if you want to set images in loop
享受!