I would like to create a CustomButton which has a predefined onClick. In fact, my object would do the same job than
CustomButton
onClick
CustomButton mB
Use that code:
class CustomButton extends Button implements View.OnClickListener{ CustomButton(Context c, AttributeSet attrs) { ... setOnClickListener(this); ... } @override public void onClick(View v){ //add your code here } }