<分区>
Possible Duplicate:
Android findViewbyId with a variant string
我在 Activity 中有这种类型的代码:
ImageButton button1 = (ImageButton)findViewById(R.id.butid1);
ImageButton button2 = (ImageButton)findViewById(R.id.butid2);
ImageButton button3 = (ImageButton)findViewById(R.id.butid3);
现在我想在 for 循环中声明这些变量。此外,将使用这些 N 按钮执行操作。例如:
for (int NUMBER = 1; NUMBER <= N; NUMBER++) {
ImageButton button"NUMBER" = (ImageButton)findViewById(R.id.butid"NUMBER");
button"NUMBER".setEnabled(false);
}
N会根据各种情况发生变化。我能做些什么来解决这个问题? (P.S. 在“同题题”中找不到结果)