我对Java很陌生。所以请原谅我问这样一个简单的问题。使用变量来指定R对象
要设置视图的背景图像,我可以做到这一点的
int TheButton = R.drawable.button1;
button.setBackgroundResource(TheButton);
但如何才能做到这一点,如果我想用一个变量来指定将R对象?
int a = 1;
int TheButton = R.drawable["button"+a]; //this is what I'll do in javascript...
button.setBackgroundResource(TheButton);