I have an activity that contains a custom view and several buttons.
Now, if the view is clicked, I’m handling it in the view class with an overwriten onTouchEvent.
However, depending on where the user clicked exactly, I might want to change the text contained in the buttons in the parent activity.
In other words: How do I make the parent activity receive data from my custom view?
Define an interface and use a callback to let the activity know that the view has been touched.
In your custom view
In your touch event
In your Activity:
You could improve the view class by adding removeViewWasTouchedListener and checking that you do not add the same listener twice in setViewWasTouchedListener.