Dynamic access to elements of the layout
<p>I have a question that is driving me crazy.</p>

<p>I have a large number of buttons (10, more or less) on my screen, inside a TableRow.</p>

<p>I need to access them, and I had planned to perform through a loop.</p>

<p>Access to one, is very easy, adding this:</p>

<pre><code>boton7 = (Button) findViewById (R.id.Btn7)
</code></pre>

<p>My question is, if you can dynamically set the id string (R.id.Btn7) to put in a can get the buttons for, and for example, change the color .... something like this:</p>

<pre><code>for (int i = 0; i &lt;10; i + +) {
   Button eachBoton= (Button) findViewById (R.id.Btn + i);
   eachBoton. setBackgroundColor (Color.Red);
}
</code></pre>

<p>That, of course, does not work .... my question is if anyone knows how exactly the chain can be mounted</p>

<pre><code>R.id.Btn + i
</code></pre>

<p>to work.</p>

<p>Thanks a lot.</p>
