title: How to handle button clicks using the XML onClick within Fragments
body: <p>Pre-Honeycomb (Android&nbsp;3), each Activity was registered to handle button clicks via the <code>onClick</code> tag in a Layout's XML:</p>
  
  <pre><code>android:onClick="myClickMethod"
  </code></pre>
  
  <p>Within that method you can use <code>view.getId()</code> and a switch statement to do the button logic.</p>
  
  <p>With the introduction of Honeycomb I'm breaking these Activities into Fragments which can be reused inside many different Activities. Most of the behavior of the buttons is Activity independent, and I would like the code to reside inside the Fragments file <em>without</em> using the old (pre 1.6) method of registering the <code>OnClickListener</code> for each button.</p>
  
  <pre><code>final Button button = (Button) findViewById(R.id.button_id);
  button.setOnClickListener(new View.OnClickListener() {
      public void onClick(View v) {
          // Perform action on click
      }
  });
  </code></pre>
  
  <p>The problem is that when my layout's are inflated it is still the hosting Activity that is receiving the button clicks, not the individual Fragments. Is there a good approach to either</p>
  
  <ul>
  <li>Register the fragment to receive the button clicks?</li>
  <li>Pass the click events from the Activity to the fragment they belong to?</li>
  </ul>