08-25-2009 07:02 AM
Hi,
I am using following code, there is no exception and err throw, label is displayed on the screen but Bitmap is not visible... Am i missing something...? Plz. help
private class AboutScreen extends MainScreen
{
private Bitmap backgroundBitmap;
private Bitmap fieldBitmap;
public AboutScreen()
{
this.setTitle("About App");
backgroundBitmap = Bitmap.getBitmapResource("logo.png");
System.out.println("Width = "+backgroundBitmap.getWidth()+ "\nheight = "+backgroundBitmap.getHeight());
vfm = new VerticalFieldManager(VerticalFieldManager.NO_HORIZ
hfm_1 = new HorizontalFieldManager(HorizontalFieldManager.USE_
{
public void paint(Graphics graphics)
{
graphics.drawBitmap(0, 0, backgroundBitmap.getWidth(), backgroundBitmap.getHeight(), backgroundBitmap, 0, 0);
super.paint(graphics);
}
};
hfm_2 = new HorizontalFieldManager(HorizontalFieldManager.USE_
s = "This is a label, I want it at the bottom of this Screen";
style = LabelField.USE_ALL_WIDTH | LabelField.FIELD_BOTTOM;
lbl_hdr = new LabelField(s,style)
{
protected void layout( int maxWidth, int maxHeight )
{
int displayWidth = 500; // As reference
int displayHeight = 120; // as reference
super.layout( displayWidth, displayHeight);
setExtent( displayWidth, displayHeight );
}
};
hfm_2.add(lbl_hdr);
vfm.add(hfm_1);
vfm.add(hfm_2);
add(vfm);
}
protected boolean onSavePrompt()
{
return true;
}
}
Solved! Go to Solution.
08-25-2009 07:35 PM
Your HorizontalFieldManager hfm_1 has no Fields in it, so has no need for any screen space, so no need to draw the background image.
I suggest that you use the paint menthod you have for the hfm_1 in the AboutScreen, i.e. overrride the AboutScreen paint method and don't use hfm_1 at all.
08-26-2009 03:36 AM
Hi Peter,
Thnx for the response..
Well, I would try as you suggestedto override the AboutScreen paint method and not using hfm_1 at all. But, I have gone thru KB article
And, in the same manner I am trying to create a background image for my application... Is somethng wrong in using it..?
08-26-2009 05:33 AM
Try to do like this,
HorizontalFieldManager hfm_1 = new HorizontalFieldManager(HorizontalFieldManager.USE_
{
int width = 50;
int height = 50;
protected void sublayout(int width, int height)
{
width = this.width;
height = this.height;
super.setExtent(width,height);
}
public void paint(Graphics graphics)
{
graphics.drawBitmap(0, 0, backgroundBitmap.getWidth(), backgroundBitmap.getHeight(), backgroundBitmap, 0, 0);
super.paint(graphics);
}
};
08-26-2009 06:23 AM
Thnx Mudassir, it worked...