title: How to use getResources().getIdentifier to get a Button id?
body: <p>I am trying to make a simple app.<br>
  I have a table with one row and seven buttons in that row.<br>
  I'm aware I don't need a 2d array, but I would like to use it.<br>
  So I can expand that later very easily. </p>
  
  <p>I am using</p>
  
  <pre><code>int resID = getResources().getIdentifier("button" + i + h, "button", getPackageName());
  </code></pre>
  
  <p>to try and get the resource id from a Button.<br>
  My Buttons are named "button00, button01, button02 etc. (that's exactly how there are in R.java).<br>
  The numbers represent the row and column respectively. 
  I've seen people use this before, but for some reason I can never get it to work. </p>
  
  <p>Here is my code for lights class</p>
  
  <pre><code>public class lights extends Activity implements OnClickListener {
  public int numRows;
  public int numCol;
  
  
  public lights(int rows, int col) {
      numRows = rows;
      numCol = col;
  }
  
  
  public void createButtonListeners(Button[][] button) {
      for (int i = 0; i &lt; numRows; i++) {
          for (int h = 0; h &lt; numCol; h++) {
              int resID = getResources().getIdentifier("button" + i + h, "button", getPackageName());
              button[i][h] = (Button) findViewById(resID);
              button[i][h].setOnClickListener((View.OnClickListener) this);
              Toast.makeText(getBaseContext(), "Made listener", Toast.LENGTH_LONG).show();
          }
      }
  }
  
  
  public void reset(Array buttons[][]) {
      for (int r = 0; r &lt; numRows; r++) {
          for (int c = 0; c &lt; numCol; c++) {
  
              //havnt got this far
          }
  
      }
  
  }
  
  
  public int wasButtonPressed() {
      for (int row = 0; row &lt; numRows; row++) {
  
  
      }
  
      return 0;
  }
  
  @Override
  public void onClick(DialogInterface dialog, int which) {
  
  }}
  </code></pre>
  
  <p>Code for Main_Activity</p>
  
  <pre><code>public class MainActivity extends Activity implements View.OnClickListener {
  
  lights mlights = new lights(1, 7);
  Button Button[][] = new Button[mlights.numRows][mlights.numCol];
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      mlights.createButtonListeners(Button);
  
  }
  
  
  @Override
  public void onClick(View v) {
  
  }}
  </code></pre>
  
  <p>I have no errors when i type my code but it does not run.<br>
  Please correct me in any possible way</p>