android - Pressing the menu button on the physical -
i have here example of such code here
public class example1activity extends activity { private static final int id_add = 1; private static final int id_accept = 2; private static final int id_upload = 3; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.example1); actionitem additem = new actionitem(id_add, "add", getresources().getdrawable(r.drawable.ic_add)); actionitem acceptitem = new actionitem(id_accept, "accept", getresources().getdrawable(r.drawable.ic_accept)); actionitem uploaditem = new actionitem(id_upload, "upload", getresources().getdrawable(r.drawable.ic_up)); //use setsticky(true) disable quickaction dialog being dismissed after item clicked uploaditem.setsticky(true); final quickaction mquickaction = new quickaction(this); mquickaction.addactionitem(additem); mquickaction.addactionitem(acceptitem); mquickaction.addactionitem(uploaditem); //setup action item click listener mquickaction.setonactionitemclicklistener(new quickaction.onactionitemclicklistener() { @override public void onitemclick(quickaction quickaction, int pos, int actionid) { actionitem actionitem = quickaction.getactionitem(pos); if (actionid == id_add) { toast.maketext(getapplicationcontext(), "add item selected", toast.length_short).show(); } else { toast.maketext(getapplicationcontext(), actionitem.gettitle() + " selected", toast.length_short).show(); } } }); mquickaction.setondismisslistener(new quickaction.ondismisslistener() { @override public void ondismiss() { toast.maketext(getapplicationcontext(), "ups..dismissed", toast.length_short).show(); } }); button btn1 = (button) this.findviewbyid(r.id.btn1); btn1.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { mquickaction.show(v); } }) button btn2 = (button) this.findviewbyid(r.id.btn2); btn2.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { mquickaction.show(v); mquickaction.setanimstyle(quickaction.anim_grow_from_center); } }); }
but want
mquickaction.show(v);
when user clicks on physical menu button btn1
. want make, menu called when user clicks on physical menu button
public boolean onkeyup(int keycode, keyevent event) { if (keycode == keyevent.keycode_menu) { mquickaction.show(this.btn1); return true; } return super.onkeyup(keycode, event); }
Comments
Post a Comment