I try to play a sound when you push any button of the app.
How is the minor intrusive way to add the listener to all buttons in the app?
Can I add overwrite (and extend) the generic listener of Android?
Thanks.
You can set one listener for all buttons and can be identified with tag also.
View.OnClickListener myClickLIstener= new View.OnClickListener() {
public void onClick(View v) {
String tag = (String) v.getTag();
Log.e("","tag : "+tag)
// your stuff
}
};
setting up listeners...
btn1.setOnClickListener(myClickLIstener);
btn1.setTag("btn1");
btn2.setOnClickListener(myClickLIstener);
btn2.setTag("btn2");
EDIT :
Are you looking for like this...
class superTop implements View.OnClickListener {
@Override
public void onClick(View v) {
Log.e("", "onClick superTop");
}
}
class NewClick extends superTop implements View.OnClickListener {
@Override
public void onClick(View v) {
Log.e("", "onClick NewClick");
super.onClick(v);
}
}
findViewById(R.id.button1).setOnClickListener(new NewClick());
You can call both the listener...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With