title: How to identify items in a logical way?
body: <p>I am new to Android development and I am trying to handle clicks on a grid of items. What is the best way to do that? So far I have something like this to set the <code>onclicklistener</code>: </p>
  
  <pre><code> TableLayout layout = (TableLayout) findViewById(R.id.tableLayout1);
      for (int i = 0; i &lt; layout.getChildCount(); i++) {
          View v = layout.getChildAt(i);
          if (v instanceof TableRow) {
              for (int j = 0; j &lt; ((TableRow)v).getChildCount(); j++) {
                  View v2 =  ((TableRow)v).getChildAt(j);
                  v2.setOnClickListener(this);
              }
          }
      }
  </code></pre>
  
  <p>Now I want to handle the clicks on the items contained in the table. As there are many items I want to avoid writing a long "switch". The items have logical IDs containing the number of the row and the column. Is there a way to get the actual ID of the item that has been clicked (the ID in the XML) and then parse it? If not, what would be the solution.</p>
  
  <p>Thanks</p>