Reputation: 628
I have a view v2 that extends another view v1. The parent view v1 has an onTouchEvent, but I would like the child view v2 to not use the onTouchEvent.
I set in the child view onTouchEvent to
@Override
public boolean onTouchEvent(MotionEvent event) {
return false;
}
Now when I create an instance of v2 in an Activity like
public class MainActivity extends AppCompatActivity implements V2.OnClickListener {
...
@Override
public void onClick(View view) {
Log.d("TAG","BLA");
}
}
The onclick event is not fired. If I make V2 not extend V1 it is fired. What am I doing wrong or is this not possible?
Upvotes: 1
Views: 160
Reputation: 936
You are just declining all touch events for this view. And the design in which child class doesn't want the parent's features is bad. Consider both V1
and V2
to inherit from View
class or create base class for them.
Upvotes: 1