开发者

Access XML using variables in android [duplicate]

开发者 https://www.devze.com 2023-04-13 01:44 出处:网络
T开发者_JS百科his question already has answers here: Android and getting a view with id cast as a string
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

精彩评论

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

关注公众号