Welcome to the Official BlackBerry® Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Regular Contributor
guydor
Posts: 65
Registered: 05-15-2011
My Carrier: Att
Accepted Solution

MenuItem error - NoClassDefFound

[ Edited ]

Hi,

 

I'm trying to add a MenuItem to my project:

protected void makeMenu (Menu menu, int instance ) {

super.makeMenu(menu, instance);

menu.add (new MyMenuItem());

}

 

class MyMenuItem extends MenuItem {

MyMenuItem() {

super(new StringProvider("Menu item text"), 100000, 0);

}

}

 

 

 

but when I click the Menu Button I receive NoClassDefFound


    Thanks,

Please use plain text.
Developer
peter_strange
Posts: 14,611
Registered: 07-14-2008

Re: MenuItem error - NoClassDefFound

Have you stepped through your code to see what is causing the problem?

 

Are you running on a suitable level of simulator given the OS level you have compiled with?

Please use plain text.
Regular Contributor
guydor
Posts: 65
Registered: 05-15-2011
My Carrier: Att

Re: MenuItem error - NoClassDefFound

I'm looking for a MenuItem which is suitable for OS 5.0 and above....

 

 

Please use plain text.
Developer
mreed
Posts: 799
Registered: 07-16-2008

Re: MenuItem error - NoClassDefFound

5.0.0 does not have the MenuItem constructor that takes a StringProvider. That was only introduced in 6.0.0. Which means you are probably compiling for 6.0.0 and running on 5.0.0, which you shouldn't do.

Please use plain text.
Regular Contributor
guydor
Posts: 65
Registered: 05-15-2011
My Carrier: Att

Re: MenuItem error - NoClassDefFound

Thank you for your reply,

 

Fix me if I'm wrong:

 

If I want my app to be compatible with both OS 5.0 & 6.0 I need to check the OS version,

If 5.0

Create a MenuItem with the constructor of OS 5.0 - http://www.blackberry.com/developers/docs/5.0.0api/net/rim/device/api/ui/MenuItem.html

if 6.0

Create a MenuItem with the constructor of OS 6.0 - http://www.blackberry.com/developers/docs/6.0.0api/net/rim/device/api/ui/MenuItem.html

 

 

???

 

Please use plain text.
Developer
uttamtts
Posts: 140
Registered: 03-15-2011
My Carrier: Airtel

Re: MenuItem error - NoClassDefFound

mreed wrote
5.0.0 does not have the MenuItem constructor that takes a StringProvider. That was only introduced in 6.0.0. Which means you are probably compiling for 6.0.0 and running on 5.0.0, which you shouldn't do.

yes you can't pass stringprovider in menuItem constructor's if you use os5.0 you can surely use it for 6.0 and above it.....
Please use plain text.