title: How exactly does the android:onClick XML attribute differ from setOnClickListener?
body: <p>From that I've read you can assign a <code>onClick</code> handler to a button in two ways.</p>
  
  <p>Using the <code>android:onClick</code> XML attribute where you just use the name of a public method with the signature<code>void name(View v)</code> or by using the <code>setOnClickListener</code> method where you pass an object that implement the <code>OnClickListener</code> interface. The latter often requires an anonymous class which personally I don't like (personal taste) or defining an internal class that implements the <code>OnClickListener</code>.</p>
  
  <p>By using the XML attribute you just need to define a method instead of a class so I was
  wondering if the same can be done via code and not in the XML layout.</p>