android - Function to Return a Buttons OnClick Listener Value -
i wondering if knew of way getting on click listener button set to. sort of like...
btn1.getonclicklistner
i want make if statement this...
if (button.onclick == onclick1) { this... } else { this... }
any appreciated
i found easiest way take commonswares advice , create 1 onclick, using booleans give separate methods execute. below example in case else gets stuck trying accomplish task. thank helped , shared thoughts.
public class mainactivity extends activity implements view.onclicklistener { boolean separateonclickactive; button btn1; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); btn1 = (button) findviewbyid(r.id.button); btn1.setonclicklistener(this); separateonclickactive = false; } @override public void onclick(view v) { switch (v.getid()) { case r.id.button: if (!separateonclickactive) { // here separateonclickactive = true; } else { //do here } break; } } }
Comments
Post a Comment