android - Launch ContextMenu when 'back' key is hit? -
i need override button launch context menu.
i have
@override public boolean onkeydown(int keycode, keyevent event) { switch (keycode) { case keyevent.keycode_back : return true; } return super.onkeydown(keycode, event); } @override public void oncreatecontextmenu(contextmenu menu, view v,contextmenuinfo menuinfo) { super.oncreatecontextmenu(menu, v, menuinfo); menu.setheadertitle("quit"); menu.add(0, v.getid(), 0, "yes"); menu.add(0, v.getid(), 0, "no"); } @override public boolean oncontextitemselected(menuitem item) { if(item.gettitle()=="yes"){quit(0);} if(item.gettitle()=="no"){quit(1);} else {return false;} return true; }
how can call contextmenu within 'case keyevent.keycode_back :'?
use opencontextmenu: you'll need pass in view want have context menu opened, should work.
Comments
Post a Comment