0

I have a list of array items, And what i need is while clicking a specific key i want to show a popup listing the array items.

public boolean onKeyUp(int keyCode, KeyEvent event)  
  {  

        switch(keyCode) {



            case KeyEvent.KEYCODE_MENU:
               keymenu();
              return true;

           }
        return false;


   } 


private void keymenu()
{
    PopupMenu menu = new PopupMenu(this, myvid);
    menu.getMenu().add("titleRes");
    menu.getMenu().add("titleRes1");
    menu.getMenu().add("titleRes2");
    menu.getMenu().add("titleRes3");
    menu.show();

}

I tried this and the pop is not showing while clicking the menu button.

Alen Abraham
  • 109
  • 1
  • 2
  • 11

1 Answers1

0

I think as suggested in this post you should override onCreateOptionsMenu() and onPrepareOptionsMenu() as the doc says

public boolean onPrepareOptionsMenu (Menu menu) Added in API level 1

Prepare the Screen's standard options menu to be displayed. This is called right before the menu is shown, every time it is shown. You can use this method to efficiently enable/disable items or otherwise dynamically modify the contents.

The default implementation updates the system menu items based on the activity's state. Deriving classes should always call through to the base class implementation.

And call your keymenu() from there.

Community
  • 1
  • 1
Shubhang Malviya
  • 1,525
  • 11
  • 17