Possible Duplicate:
Android findViewbyId with a variant string
I have this type of code within an Activity:
ImageButton button1 = (ImageButton)findViewById(R.id.butid1);
ImageButton button2 = (ImageButton)findViewById(R.id.butid2);
ImageButton button3 = (ImageButton)findViewById(R.id.butid3);
Now I want to declare these variables within a for-loop. Also, actions will be taken with these N buttons. For example:
for (int NUMBER = 1; NUMBER <= N; NUMBER++) {
ImageButton button"NUMBER" = (ImageButton)findViewById(R.id.butid"NUMBER");
button"NUMBER".setEnabled(false);
}
N will change depending on various situations. What can I do best to solve this? (P.S. Couldn't find the result in the "Questions with similar titles")