I have created some extended UI controls based on the default android widgets (Button, ProgressBar). At some point, in the custom control, I want to communicate with the view that contains the custom control. For example, I want to pass the current value of the ProgressBar or a value from the Button.
What is the best approach? Is it possible to create a custom event (like the “onClick”) and then have in the container class an handler? Or there is some better approach?
Thank you in advance! 😉
I have created some extended UI controls based on the default android widgets (Button,
Share
If the “some point” is when an event happens (like when you press the button) you can create an event listener interface.
Inside a custom view of mine I put this:
this way I can implement
OnFlingListeneras I would do withOnClickListener.EDIT:
my
onFlingreturns a boolean because I wanted to decide in there if to accept or cancel the event (seeflingRight()). It could also return void.