08-28-2008 08:34 AM
Is there some trick to this on the Blackberry Pearl.
I want an Image and then text to the right of the image as the first line
in a configuration form. I am trying to support the Pearl 8110 and so on
It only puts the Image on a line by itself no matter what layout combos
I use
try {
Image image=Toolkit.createImage("/tivoli.png");
ImageItem it=new ImageItem("",image,Item.LAYOUT_2|Item.LAYOUT_SHRIN
sf.append(it);
} catch (Exception e) {
}
StringItem si = new StringItem("","a"+tbsmNLS.get("label-conf")+"\n");
si.setFont(Font.getFont(Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_MEDIUM));
si.setLayout(Item.LAYOUT_2);
The WTK emulator works fine for every combo I seem to think would work
and I am getting tired of building and trying to test on the
real device to get it to work. The image and string very easilly can fit on a row.
Also this works fine a Nokia E60
Solved! Go to Solution.
08-28-2008 11:58 AM
Just gave in and wrote my own label
package com.ibm.tivoli.midp;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class ImageString extends CustomItem {
Image img;
String st;
Font font;
public ImageString(Image image, String title){
super("");
font=Font.getFont(Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_MEDIUM);
img = image;
st = title;
}
protected int getMinContentHeight() {
return img.getHeight();
}
protected int getMinContentWidth() {
return img.getWidth()+font.stringWidth(st)+5;
}
protected int getPrefContentHeight(int width) {
return img.getHeight();
}
protected int getPrefContentWidth(int height) {
return img.getWidth()+font.stringWidth(st)+5;
}
protected void paint(Graphics g, int w, int h) {
g.drawImage(img,0,0,Graphics.LEFT|Graphics.TOP);
g.setFont(font);
g.drawString(st,img.getWidth(),img.getHeight()-fon
Graphics.LEFT|Graphics.TOP);
}
protected boolean traverse(int dir, int viewportWidth, int viewportHeight,
int[] visRect_inout) {
return true;
}
protected void sizeChanged(int w, int h){
}
}