title: How to add event handler when creating dynamically created view in Android?
body: <p>I have created all view dynamically in android studio.</p>
  
  <p>Ex:  </p>
  
  <pre><code>RelativeLayout big = new RelativeLayout(this);  
  for(int i=0; i&lt;50; i++)
  {
     RelativeLayout mini = new RelativeLayout(this);  
     TextView t = new TextView(this);  
     mini.addView(t);  
     big.addView(mini);
  }
  </code></pre>
  
  <p>Now, in the sample code, I want to add events like <strong>onTouch</strong>, <strong>onClick</strong> etc. for all the '<strong>mini</strong>' RelativeLayouts which will change the <strong>backgroundColor</strong> of the touched/clicked RelativeLayout. Can I do that in single function?</p>
  
  <p>Actually, I am new in Android apps developing. I have handled events in VB.net with ease<br>
  (Ex. </p>
  
  <pre><code>AddHandler mini.Click, AddressOf Clicked  
  //sample example
  Public Clicked(Byval sender As Object, e As EventArgs)
     sender.BackColor=Color.Black
  End Sub
  </code></pre>
  
  <p>)</p>
  
  <p>I want to do like this in java(android), is it possible?</p>