mahercbeaucoup
mahercbeaucoup

Reputation: 597

How to hook into all Android click events?

I'm looking for a relatively simple method of hooking into all click events in already existing code. Whenever a click occurs, I want the already assigned click event handler to run, and then I want to run the additional click handler that will do whatever I need it to do. Essentially, I want a simple way of adding a new OnClickListener to everything that can accept it.

For each component c
  add extra OnClickListener to c

Upvotes: 1

Views: 1532

Answers (1)

CommonsWare
CommonsWare

Reputation: 1007276

There is no notion of an "extra" listener for these sorts of events -- there is only one per widget.

You could create your own CompositeOnClickListener that holds onto 1+ OnClickListener objects and passes click events to all of them. However, there is no getOnClickListener() method on View, so there would be no way for you to apply it across the board.

Hence, as @Falmarri indicates, I doubt that this is really possible.

Upvotes: 1

Related Questions