title: Dynamically creating buttons with setOnClickListener
body: <p>I am dynamically creating buttons and I need to dynamically setting the <code>setOnClickListener()</code>  I am currently trying to use the below code but it gives me this syntax error:</p>
  
  <pre><code>private void AddButton(){
      Button btn = new Button(this);
      btn.setOnClickListener(OnClick(this));
  
      layout.addView(delBtn);
  }
  
  public void OnClick(View v) {
      Log.d("Button", "Dynamically created button was clicked");
  }
  </code></pre>
  
  <p><code>"The method OnClick(View) in the type ActivityExample is not applicable for the arguments ()"</code></p>
  
  <p>How do I resolve this?</p>
  
  <p><strong>EDIT:</strong> I need to have the button on click listener method out of the <code>AddButton()</code> method</p>