开发者

Access XML using variables in android [duplicate]

T开发者_JS百科his question already has answers here: Android and getting a view with id cast as a string (2 answers) Closed 8 years ago.

I want access to a picture using

image.setImageResource(R.drawable.photo1);

How can I change "photo1" to "photo" + # (incremented number) so that I can use it with an iteration?


int resID = getResources().getIdentifier("photo"+1,"drawable", getPackageName());
image.setImageResource(resID); 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜