title: Android button onclick override
body: <p>I would like to create a <code>CustomButton</code> which has a predefined <code>onClick</code>.
  In fact, my object would do the same job than</p>
  
  <pre><code>CustomButton mButton = getViewById(..);
  mButton.setOnClickListener(new OnClickListener() {
  @Override
  public void onClick(View v) {
    show_something()
  }
  </code></pre>
  
  <p>Is there a way to embed the <code>Listener</code> into the CustomButton object that inherits from Button ? 
  What I would like is to create a <code>CustomButton</code> in my layout XML file, and not having to mention this button in my activity, which would give:</p>
  
  <p>main.xml:</p>
  
  <pre><code>&lt;LinearLayout xmlns:"..."&gt;
       &lt;com.mypackage.view.CustomButton
           (attributes)/&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>CustomButton.java:</p>
  
  <pre><code>class CustomButton extends Button implements... {
  
  @Override
  OnClick (or something like that, that's the core of my question, what to put here)
  }
  </code></pre>
  
  <p>myActivity.java</p>
  
  <pre><code>public class myActivity extends Activity {
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
      }
  }
  </code></pre>
  
  <p>Thanks a lot. </p>