title: Android - attach data to views
body: <p>In my application I create dynamic rows in table much as in this tutorial:
  <a href="http://en.androidwiki.com/wiki/Dynamically_adding_rows_to_TableLayout" rel="noreferrer">http://en.androidwiki.com/wiki/Dynamically_adding_rows_to_TableLayout</a></p>
  
  <pre><code> for(int i = startDay; i &lt; startDay + 7; i++){
  
        /* Create a TextView to be the row-content. */
        TextView day = new TextView(this);
        day.setText(Integer.toString(i));
        day.setLayoutParams(new LayoutParams(
                  LayoutParams.FILL_PARENT,
                  LayoutParams.WRAP_CONTENT));
  
        day.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.i("Listener: ", "Click");
            }
  </code></pre>
  
  <p>So now when I click on a TextView I can register click event, but how do I determine which TextView was clicked?</p>
  
  <p>Not just an object which I get with an event but data like which day number was clicked?</p>
  
  <p>Ideally I would want to have data attached to every view I create dynamically.
  Something like data() method in Javascript jQuery. </p>
  
  <p>Right now I can see only 1 way to solve this - while creating TextView add id with data and when clicked - get id back and parse it to get my data. But it strikes me as ugly approach.</p>
  
  <p>Is there a way to attach arbitrary data to android views?</p>