title: Creating custom control with overriding onclick
body: <p>I am working on an android app and I have a custom GUI component which extends a TextView. </p>
  
  <p>I want to have my custom control do a task when clicked from my custom control class and my overridden onclick method. </p>
  
  <p>For example my class that extends the TextView implements the OnClick listener and writes a log to the log cat. </p>
  
  <p>Then in my activity, I set an onclick listener to my custom control, and this shows a toast notification. </p>
  
  <p>What I want to happen, is when my custom control is clicked, my activities overridden onclick shows the toast and the custom control class on click method also is run to show the log. But I can only seem to get one working or the other, for example, if I don't run myCustom.setOnClickListener(myListener) then the classes onclick is used and does the log, if I set the onClick listener then I only get the toast not the log. </p>
  
  <p>Below is my custom control class</p>
  
  <pre><code>public class NavTextView extends TextView implements View.OnClickListener
  {
      public NavTextView(Context context) {
          super(context);
          setOnClickListener(this);
      }
  
      public NavTextView(Context context, AttributeSet attrs) {
          super(context, attrs);
          setOnClickListener(this);
      }
  
      public NavTextView(Context context, AttributeSet attrs, int defStyleAttr) {
          super(context, attrs, defStyleAttr);
          setOnClickListener(this);
      }
  
      public NavTextView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
          super(context, attrs, defStyleAttr, defStyleRes);
          setOnClickListener(this);
      }
  
      @Override
      public void onClick(View v) {
          Log.d("NavTextView", "This has been clicked");
      }
  }
  </code></pre>
  
  <p>Below is my activities onCreate method</p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          navTextView = (NavTextView)findViewById(R.id.navTextView);
  
          navTextView.setOnClickListener(mClickListener);
      }
  </code></pre>
  
  <p>Hope this makes sense</p>