Using Global Onclicklistener
Is it possible to make an onClickListener app-global? I basically have several fragments that will use the same numpad buttons for input and instead of registering and filtering cl
Solution 1:
Yes, as dymmeh has shown. But the proper way is probably to create your own view component containing all the numpad buttons. You would need to define a layout file, and create a class which would extend some kind of ViewGroup
(see compound controls).
This custom component would take care of onClick events of buttons inside it. You could then expose some kind of interface (listener) for activities and fragments to attach to if you need them to react for higher-level events.
Then, you would just include your custom component in any layouts you need instead of copypasting a bunch of buttons and the onClick listener-attaching code.
Post a Comment for "Using Global Onclicklistener"