title: How to use a simple code determine actions for an array of square images
body: <p>I'm starting to learn about Android application development and so I'm working on some small apps to exercise programming and better understand some stuff.</p>
  
  <p>The situation is as follows:</p>
  
  <p>I have 25 square images as a 5x5 array, and I want to specify a different action for clicking on each one. </p>
  
  <p>I declared the images IDs as matrix elements:</p>
  
  <pre><code>square11, square12, ... square15
  square21, square22, ... square25
    ...      ...            ...
  square51, square52, ... square55
  </code></pre>
  
  <p>I tried to do something like this:</p>
  
  <pre><code>public void onClick(View v){
      switch(v.getId()){
          case R.id.square11:
              //do something
              break;
          case R.id.square12:
              //do something
              break;
          case R.id.square13:
              //do something
              break;
          case R.id.square14:
              //do something
              break;
          //and all other cases...
      }
  }
  </code></pre>
  
  <p>But clearly it's not working. Am I missing something about this <code>OnClickListener</code>?</p>
  
  <p>Probably it's a newbie's question, but I hope someone can help. I really looked at other code, but they didn't seem to help.</p>
  
  <p>The thing is, do you know what am I doing wrong? And better, do you know if there is a better and cleaner way to do this?</p>
  
  <p>Thanks a lot!</p>
  
  <p>Best regards,</p>
  
  <p>Rafael</p>