I created nine Button view in the main.xml and named it to Button1, Button2... Button9.. Then in my code I created an ArrayList of Button and its obvious that this array of buttons will hold my Button in the main.xml and in my current knowledge that to get the Button in my main.xml I need to use the findViewById method and basically I need to loop the array to get the button
ArrayList<Button> buttons;
int MAXBTN = 9;
for( int i = 0; i < BTN; i++ )
{
// Code here to use the findViewById method to get the button
}
And my problem is that I need to pass R.id.Button1 .. R.id.Button3 to the findViewById method, but I need to loop this. Is there anyway I can pass a counter in the findViewById while loop?
Please advise.