Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
Posts: 21
Registered: ‎03-26-2012
My Device: balck berry 9550

Menu item events in address book

I succeed to add an item to the menu items of contacts but when I click on the item its not work unless that second items appear this is the code I used

public class MyApp extends UiApplication
{
    public static void main(String[] args)
    {
           if (args == null || args.length == 0) {
        MyApp theApp = new MyApp();       
        theApp.enterEventDispatcher();}
           
    }
    public MyApp()
    {    
        pushScreen(new MyScreen());
        ContactsMenuItem menuItem = new ContactsMenuItem();
        ApplicationMenuItemRepository
        .getInstance().addMenuItem
        (ApplicationMenuItemRepository
          .MENUITEM_EMAIL_VIEW,menuItem);

    }    
    private static class ContactsMenuItem extends ApplicationMenuItem {
        ContactsMenuItem( ) {
          super(0);
          
        }
    public String toString() {
          return "myapp";
        }    
    public Object run(Object context) {
          try {
            System.out.println("Entered run method");
              Dialog.alert("Entered run method");
          } catch (Exception e) {
            e.printStackTrace();
          }        
          return context;
        
        }
      }
}

i made some search but didn't find the solution may someone can help me

thx  on advance

Developer
Posts: 16,574
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Menu item events in address book

what do you mean with "second item"?
what do you mean with "menu items of contacts"? you add it to the email view.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Contributor
Posts: 21
Registered: ‎03-26-2012
My Device: balck berry 9550

Re: Menu item events in address book

i added it to MENUITEM_ADDRESSBOOK_LIST ,MENUITEM_ADDRESSCARD_VIEW and MENUITEM_EMAIL_VIEW and all gave same solution cant call the run methode   and  second items means that the same items appear twice 

so how to solve this situation

Developer
Posts: 107
Registered: ‎05-26-2011
My Device: Torch

Re: Menu item events in address book

I have used the same code and it is working fine.

 

Contributor
Posts: 21
Registered: ‎03-26-2012
My Device: balck berry 9550

Re: Menu item events in address book

i resolved it ,the problem was in the   api level its not worked with 7.1 api so i solved it with jre6 its work like charm

but by the way its possible to made submenu to the same code with mre than item did anyone have idea how to make that thx for help

Developer
Posts: 16,574
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Menu item events in address book

no, there is no submenu for applicationmenuitems.
you can open a popupscreen with a selection, for example.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter