title: Android: Using findViewById() with a string / in a loop
body: <p>I'm making an android application, where there is a view composed of hundreds of buttons, each with a specific callback. Now, I'd like to set these callbacks using a loop, instead of having to write hundreds of lines of code (for each one of the buttons). </p>
  
  <p>My question is: How can I use findViewById without statically having to type in each button id? 
  Here is what I would like to do:</p>
  
  <pre><code>    for(int i=0; i&lt;some_value; i++) {
         for(int j=0; j&lt;some_other_value; j++) {
          String buttonID = "btn" + i + "-" + j;
          buttons[i][j] = ((Button) findViewById(R.id.buttonID));
          buttons[i][j].setOnClickListener(this);
         }
      }
  </code></pre>
  
  <p>Thanks in advance!</p>