title: Unable to create a custom button with click listener
body: <p>I am new to Android and wanted to create a custom click listener,but the below code causes no action when i click on the button.Can someone please guide me</p>
  
  <p>Code for MainActivity:</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
      CustomButton button;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          button = findViewById(R.id.custombutton);
          button.setClickListener(new CustomButton.OnClickListener() {
              @Override
              public void onClick(View var1) {
                  Toast.makeText(MainActivity.this, "SGB Custom Button", Toast.LENGTH_SHORT).show();
              }
          });
  
  
      }
  
  }
  </code></pre>
  
  <p>Code for Custom Button:</p>
  
  <pre><code>public class CustomButton extends android.support.v7.widget.AppCompatButton {
      public OnClickListener event;
  
      public CustomButton(Context context) {
          super(context);
      }
  
      public CustomButton(Context context, AttributeSet attrs) {
          super(context, attrs);
      }
  
      public CustomButton(Context context, AttributeSet attrs, int defStyleAttr) {
          super(context, attrs, defStyleAttr);
      }
  
  
      public void setClickListener(OnClickListener event) {
          this.event = event;
      }
  
      public interface OnClickListener {
          public void onClick(View var1);
      }
  }
  </code></pre>