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
Developer
Posts: 298
Registered: ‎05-02-2010
My Device: Bold 9700
Accepted Solution

What is a good implementation of creating MenuItems from records in a SQLite database?

From my understanding and reading the MenuItem API KB, I need to extend the MenuItem class for each menu item that I want to create.

 

 

 ...
    // setup the menu items
    MenuItem item = new MyMenuItem();
    menu.addItem(item);
    ...
    class MyMenuItem extends MenuItem {
        MyMenuItem() {
            super(MyResourceBundle.getBundle(), MyResource.MY_MENU_ITEM, 0, 100);
        }
        public void run() {
            // do something
        }
    }

 

I return a list of five to eight records from a SQLite database and I want each record's label (String) to be a label for the menu item .

 

Do I just loop through the records and create a MenuItem for each record and add the menu item to the menu within the loop?

 

for(each record){

create MenuItem

add MenuItem to menu

}

 

Or is there a good implementation for this?

 

Thanks,

 

--Todd

Windows 7 Enterprise 64-bit (6.1 Build 7600) | Java SE Runtime Environment (build 1.6.0_24-b07) | Eclipse Version: 3.6.2 [M20110210-1200] | BlackBerry Eclipse Plug-in: 1.3.0.201102031007-19 | Java Compiler level: 1.3 | Targeting devices running OS 5 | Simulators: JDE 5.0 packaged 9700, 9630, 9300
Developer
Posts: 16,574
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: What is a good implementation of creating MenuItems from records in a SQLite database?

your workflow looks good.

----------------------------------------------------------
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
Developer
Posts: 19,612
Registered: ‎07-14-2008
My Device: Not Specified

Re: What is a good implementation of creating MenuItems from records in a SQLite database?

Slight variation:

 

    class MyMenuItem extends MenuItem {
        MyMenuItem(String menuLabel) {
            super(menuLabel, 0, 100);
        }
        public void run() {
            // do something
        }
    }

 

for(each record){

extract label

create MenuItem(label)

add MenuItem to menu

}