Answer the question
In order to leave comments, you need to log in
How can an entire array be given the same value in java?
There is an array of buttons:
For example
private final int COUNT = 9;
private Button[] btn= new Button[COUNT];
btn[0] = (Button) findViewById(R.id.button1);
btn[1] = (Button) findViewById(R.id.button2);
btn[2] = (Button) findViewById(R.id.button3);
btn[3] = (Button) findViewById(R.id.button4);
btn[4] = (Button) findViewById(R.id.button5);
btn[5] = (Button) findViewById(R.id.button6);
btn[6] = (Button) findViewById(R.id.button7);
btn[7] = (Button) findViewById(R.id.button8);
btn[8] = (Button) findViewById(R.id.button9);
Answer the question
In order to leave comments, you need to log in
It is necessary to loop through all child in the parent element and assign a value.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question