BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 07-13-2009, 02:38 PM   #1 (permalink)
New Member
 
Join Date: Jul 2009
Model: 7100T
PIN: N/A
Carrier: verizon
Posts: 4
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default GIF Image display

Please Login to Remove!

I want to add a menu in my application, clicking on which should display a GIF image.below is the code using which i get a blank screen.

public class LegendScreen extends MainScreen {

public static final String ID = "LegendScreen";
private static final String LEGEND = "legend.file";
private BitmapField legendField;
private Bitmap legendImage;
private Properties conf;

public LegendScreen(Properties conf) {

this.conf = conf;
add(legendField);
}

protected void onDisplay() {
super.onDisplay();

legendImage = Bitmap.getBitmapResource(conf.get( LEGEND ));
legendField = new BitmapField(legendImage);

}

}

I have created the manu correctly. To display image, is this the right approach?

Thanks.
Offline  
Old 07-13-2009, 02:54 PM   #2 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

I'm having some difficulty following your logic.

Where is the menu item you refer to? How is the code above called?

You are adding a null BitmapField in the constructor - do you expect this to somehow display your image, though the object is null?
Offline  
Old 07-13-2009, 03:36 PM   #3 (permalink)
New Member
 
Join Date: Jul 2009
Model: 7100T
PIN: N/A
Carrier: verizon
Posts: 4
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

hey, its working now, there were some silly errors.

I am creating menu as,

public class Menu{

private static final String LEGEND = "menu.legend";
private Properties conf;

public Menu( Properties conf ) {
this.conf = conf;
}

public MenuItem[] createMenu() {
ItemInfo legend = new ItemInfo( conf.get( LEGEND ) );

return new MenuItem[] {
new SwitchScreenMenuItem( legend.text, legend.ordinal, legend.priority, LegendScreen.ID ),
};


From main.java i called it using,
screens.add( new LegendScreen(props), LegendScreen.ID );

So, on clicking 'Legends' menu,
application automatically switches to LegendScreen & displays the image.
-------------------------------------------------------------------

However, this is not exactly what i want. I want a menu item "Show Legend" which will display the legend icon. Now menu should change to "Hide Legend" clciking on which will undisplay the legend icon.

Any pointers or sample code for this?

Thanks.
Offline  
Old 07-13-2009, 04:58 PM   #4 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

Then you need a state variable "legendDisplayed" so that you can toggle between the two menu items based on the state.

Create two menu items, one for "Display" , the other "Hide".

Override makeMenu() in your screen and add the appropriate MenuItem based on value Of "legendDisplayed".
Offline  
Old 07-13-2009, 06:25 PM   #5 (permalink)
New Member
 
Join Date: Jul 2009
Model: 7100T
PIN: N/A
Carrier: verizon
Posts: 4
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks. can you please share a sample code for this.
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.