02-10-2012 02:50 PM
Hi,
I am using blackberry 4.7 and creating a custom popup screen having a background image(border at boundary) and large text. Everything is fine but getting right border line missing. Here is my code:
public CustomPopup(String helpTxt) {
// TODO Auto-generated constructor stub
super(new VerticalFieldManager(VerticalFieldManager.NO_VERTI
VerticalFieldManager vfm = new VerticalFieldManager(Manager.VERTICAL_SCROLL|Manag
RichTextField rtf = new RichTextField(helpTxt);
vfm.add(rtf);
add(vfm);
}
protected void paint(Graphics graphics) {
// TODO Auto-generated method stub
Bitmap img = resizeBitmap(popupImg, getWidth(), getHeight());
graphics.drawBitmap(0, 0, getWidth(), getHeight(),img, 0, 0);
super.paint(graphics);
}
protected void applyTheme() {}
I tried a lot but not getting solution yet.
Please Help.
02-10-2012 11:50 PM
Jst try this
class CustomPopup extends PopupScreen
{
Bitmap img;
public CustomPopup(String helpTxt) {
// TODO Auto-generated constructor stub
super(new VerticalFieldManager(VerticalFieldManager.NO_VERTI CAL_SCROLL));
img = Bitmap.getBitmapResource("vista-theme-red.png");
VerticalFieldManager vfm = new VerticalFieldManager(Manager.VERTICAL_SCROLL|Manag er.VERTICAL_SCROLLBAR);
RichTextField rtf = new RichTextField(helpTxt);
vfm.add(rtf);
add(vfm);
}
protected void paint(Graphics graphics) {
// TODO Auto-generated method stub
graphics.drawBitmap(0, 0, img.getWidth(), img.getHeight(),img, 0, 0);
super.paint(graphics);
}
protected void sublayout(int paramInt1, int paramInt2) {
super.sublayout(img.getWidth(), img.getHeight());
setExtent(img.getWidth(), img.getHeight());
}
}call this from any mainscreen
like
if(field==btn){
UiApplication.getUiApplication().pushScreen(new CustomPopup("Hello good morning "));
}you can get out put as following
02-18-2012 08:29 AM
Can I just say that resizing a Bitmap in paint is a significant overhead.
You have this:
protected void paint(Graphics graphics) {
// TODO Auto-generated method stub
Bitmap img = resizeBitmap(popupImg, getWidth(), getHeight());
so everytime your screen gets painted the bitmap is resized.
The best way to do this is override sublayout and size it in there. If you can't figure out how to do this, at least keep a class level Bitmap which references the resized Bitmap and only resize it when your class Bitmap does not exist or its size does not match.