Monday, 15 July 2013

android - How add a general listener for all buttons (no intrusive)? -



android - How add a general listener for all buttons (no intrusive)? -

i seek play sound when force button of app.

how minor intrusive way add together listener buttons in app?

can add together overwrite (and extend) generic listener of android?

thanks.

you can set 1 listener buttons , can identified tag also.

view.onclicklistener myclicklistener= new view.onclicklistener() { public void onclick(view v) { string tag = (string) v.gettag(); log.e("","tag : "+tag) // stuff } };

setting listeners...

btn1.setonclicklistener(myclicklistener); btn1.settag("btn1"); btn2.setonclicklistener(myclicklistener); btn2.settag("btn2");

edit :

are looking 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 phone call both listener...

android

No comments:

Post a Comment