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

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -