java - Open a contextual menu bar upon menu click -
i'm wondering if there way open contextual menu bar upon click on phones menu button in android. create contextual menu bar according basic tutorial: tutorial contextual menu bar
and have following in activity:
mcallback = new callback(){ @override public boolean onactionitemclicked(actionmode mode, menuitem item) { switch(item.getitemid()){ case 1: toast.maketext(getbasecontext(), "selected action1 " + postid, toast.length_short).show(); //mode.finish(); // automatically exists action mode, when user selects action break; case 2: toast.maketext(getbasecontext(), "selected action2 " + postid, toast.length_short).show(); //mode.finish(); // automatically exists action mode, when user selects action break; case 3: toast.maketext(getbasecontext(), "selected action3 " + postid, toast.length_short).show(); //mode.finish(); // automatically exists action mode, when user selects action break; } return false; } @override public boolean oncreateactionmode(actionmode mode, menu menu) { mode.settitle("actions post"); getmenuinflater().inflate(r.menu.context_menu_posts, menu); menu.add(1, 1, 1, "option 1"); menu.add(1, 2, 2, "option 2"); menu.add(1, 3, 3, "option 3"); return true; } @override public void ondestroyactionmode(actionmode mode) { mmode = null; } @override public boolean onprepareactionmode(actionmode mode, menu menu) { return false; } };
but want "show" when user clicks menu button. before had code in longclicklistener:
if(mmode!=null) return false; else mmode = startactionmode(mcallback);
this worked great control in activity there way menu click? tried putting code startactionmode in @overriden menu methods can't open upon click on menu button.
thanks in advance!
sorry stupid post, must more tired thought.
wasn't thinking override menubutton , add code there, since i'm not using before.
this post solved me:intercept menuclick
Comments
Post a Comment