In general, I make a custom view based on TextView. I create a class this way

public class DayView extends TextView implements TextView.OnClickListener 

and accordingly I process the onClick method onClick . The clickable property tried to set both in the code via setClickable() , and through the android:clickable="true" markup android:clickable="true" , but for some reason the handler is not called after the click. The second day is already fighting.

  • The question was solved by adding the 'onClickListener (this)' method during initialization. blunted) - Artur
  • I beat you to 6c) - Yuriyi SPb
  • 2
    it was enough to ask a question yesterday) as a result, immediately I found the solution myself) or rather my joint) - Artur
  • If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Nicolas Chabanovsky

2 answers 2

Something like this ... everything works

 public class ExtTextView extends TextView implements View.OnClickListener { public ExtTextView(Context context) { super(context); init(); } public ExtTextView(Context context, AttributeSet attrs) { super(context, attrs); init(); } public ExtTextView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(); } private void init(){ setOnClickListener(this); } @Override public void onClick(View v) { } } 

    The fact that you have defined a click handler does not mean that it will automatically be called. Try assigning it to an instance of your class:

     DayView dayView = ...; dayView.setOnClickListener(dayView); 

    Or directly in the custom class:

     setOnClickListener(this);