C
C
Chvalov2015-08-27 19:16:27
Java
Chvalov, 2015-08-27 19:16:27

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);

How can all btn[] buttons be set to setEnabled(false); ?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
Chvalov, 2015-08-27
@Chvalov

for (int i = 0; i < COUNT; i++) {
            btn[i].setEnabled(false);
        }

R
Rustem Saitkulov, 2015-08-28
@atetc

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 question

Ask a Question

731 491 924 answers to any question